/*
 SmartFoxServer 2X HTML5/JavaScript API
 (c) gotoAndPlay | All rights reserved
 http://www.smartfoxserver.com
 */
SFS2X = {SmartFox: function (a) {
    this._majVersion = 1;
    this._subVersion = this._minVersion = 0;
    this._socketEngine = new SFS2X.SocketEngine;
    this._eventDispatcher = new SFS2X.EventDispatcher;
    this._lagMonitor = null;
    this._log = SFS2X.Logger;
    this._inited = this._isJoining = !1;
    this._currentZone = null;
    this.version = this._majVersion + "." + this._minVersion + "." + this._subVersion;
    this.config = a;
    this.debug = !1;
    null != this.config && this.config.debug && (this.debug = !0);
    this.logger = this._log;
    this.lastJoinedRoom = this.mySelf = this.buddyManager = this.userManager =
        this.roomManager = this.sessionToken = null;
    this._controllers = {};
    this._initialize();
    this._log.info("SmartFox instance ready!")
}};
SmartFox = SFS2X.SmartFox;
SFS2X.SmartFox.prototype.addEventListener = function (a, b, c) {
    this._eventDispatcher.addEventListener(a, b, c)
};
SFS2X.SmartFox.prototype.removeEventListener = function (a, b) {
    this._eventDispatcher.removeEventListener(a, b)
};
SFS2X.SmartFox.prototype.connect = function (a, b) {
    if (this.isConnected())this._log.warn("Already connected"); else if (this._socketEngine.isConnecting)this._log.warn("A connection attempt is already in progress"); else {
        var c = null != this.config && null != this.config.host ? this.config.host : null, d = null != this.config && null != this.config.port ? this.config.port : null;
        null != a && (c = a);
        null != b && (d = b);
        null == c || 0 == c.length ? this._log.error("Invalid connection host/address") : "number" != typeof d || 0 > d || 65535 < d ? this._log.error("Invalid TCP port") :
            this._socketEngine.connect(c, d)
    }
};
SFS2X.SmartFox.prototype.disconnect = function () {
    this.isConnected() ? (0 < this._socketEngine.reconnectionSeconds && this.send(new SFS2X.Requests.System.ManualDisconnectionRequest), setTimeout(function (a) {
        a._handleClientDisconnection(SFS2X.Utils.ClientDisconnectionReason.MANUAL)
    }, 100, this)) : this._log.info("You are not connected")
};
SFS2X.SmartFox.prototype.enableLagMonitor = function (a, b, c) {
    null == this.mySelf ? this._log.warn("Lag Monitoring requires that you are logged in a Zone; please retry after completing the login process") : (null != this._lagMonitor && this._lagMonitor.destroy(), a && (this._lagMonitor = new SFS2X.Utils.LagMonitor(this, b, c), this._lagMonitor.start()))
};
SFS2X.SmartFox.prototype.isConnected = function () {
    return null != this._socketEngine ? this._socketEngine.isConnected : !1
};
SFS2X.SmartFox.prototype.getMaxMessageSize = function () {
    return null != this._socketEngine ? this._socketEngine._maxMessageSize : 0
};
SFS2X.SmartFox.prototype.send = function (a) {
    if (this.isConnected())if (null == a.validate || null == a.execute)this._log.error("An invalid request was passed: " + a), this._log.debug("Object dump:\n" + SFS2X.DebugHelper.getDump(a)); else {
        try {
            a.validate(this), a.execute(this)
        } catch (b) {
            if (b instanceof SFS2X.Exceptions.SFSValidationError && null != b.getMessage) {
                a = b.getMessage();
                if (null != b.getErrors())for (var a = a + ":", c = 0; c < b.getErrors().length; c++)1 < b.getErrors().length && (a += " " + (c + 1) + ")"), a += " " + b.getErrors()[c];
                this._log.error("Request failed | " +
                    a)
            } else throw b;
            return!1
        }
        this.debug && (this._log.info("OUTGOING DATA\n" + SFS2X.DebugHelper.getDump(a.getMessage())), this._log.info("OUT > " + SFS2X.Requests.getRequestNameFromId(a._id)));
        this._socketEngine.send(a.getMessage());
        return!0
    } else this._log.error("You are not connected. Request cannot be sent: " + SFS2X.Requests.getRequestNameFromId(a._id))
};
SFS2X.SmartFox.prototype.getRoomById = function (a) {
    return this.roomManager.getRoomById(a)
};
SFS2X.SmartFox.prototype.getRoomByName = function (a) {
    return this.roomManager.getRoomByName(a)
};
SFS2X.SmartFox.prototype.getRoomList = function () {
    return this.roomManager.getRoomList()
};
SFS2X.SmartFox.prototype.getRoomListFromGroup = function (a) {
    return this.roomManager.getRoomListFromGroup(a)
};
SFS2X.SmartFox.prototype.getJoinedRooms = function () {
    return this.roomManager.getJoinedRooms()
};
SFS2X.SmartFox.prototype._initialize = function () {
    this._inited || (this._socketEngine = new SFS2X.SocketEngine(this), this._socketEngine.addEventListener(SFS2X.SocketEvent.CONNECT, this._onSocketConnect, this), this._socketEngine.addEventListener(SFS2X.SocketEvent.DISCONNECT, this._onSocketDisconnect, this), this._socketEngine.addEventListener(SFS2X.SocketEvent.DATA, this._onSocketData, this), this._socketEngine.addEventListener(SFS2X.SocketEvent.IOERROR, this._onSocketIOError, this), this._controllers[0] = new SFS2X.Controllers.SystemController(this),
        this._controllers[1] = new SFS2X.Controllers.ExtensionController(this), this._inited = !0, this._reset())
};
SFS2X.SmartFox.prototype._reset = function (a) {
    this.userManager = new SFS2X.Managers.GlobalUserManager(this);
    this.roomManager = new SFS2X.Managers.RoomManager(this);
    this.buddyManager = new SFS2X.Managers.BuddyManager(this);
    null != this._lagMonitor && this._lagMonitor.destroy();
    this._isJoining = !1;
    this.mySelf = this.lastJoinedRoom = this._currentZone = null;
    a && (this.sessionToken = null)
};
SFS2X.SmartFox.prototype._dispatchEvent = function (a, b) {
    this._eventDispatcher.dispatchEvent(a, b)
};
SFS2X.SmartFox.prototype._onSocketConnect = function (a) {
    a.success ? (a = new SFS2X.Requests.System.HandshakeRequest(this.version, a.isReconnection ? this.sessionToken : null), this.send(a)) : this._dispatchEvent(SFS2X.SFSEvent.CONNECTION, {success: !1})
};
SFS2X.SmartFox.prototype._onSocketDisconnect = function (a) {
    this._dispatchEvent(SFS2X.SFSEvent.CONNECTION_LOST, {reason: a.reason});
    this._reset(!0)
};
SFS2X.SmartFox.prototype._onSocketData = function (a) {
    this.debug && this._log.info("INCOMING DATA\n" + SFS2X.DebugHelper.getDump(a));
    var b = a[SFS2X.Controllers.CONTROLLER_ID], c = a[SFS2X.Controllers.ACTION_ID], a = a[SFS2X.Controllers.PARAM_ID];
    null == b ? this._log.error("Message rejected: Controller ID is missing") : null == b ? this._log.error("Message rejected: Action ID missing") : this._controllers[b].handleMessage(a, c)
};
SFS2X.SmartFox.prototype._onSocketIOError = function (a) {
    this._dispatchEvent(SFS2X.SFSEvent.SOCKET_ERROR, {message: a})
};
SFS2X.SmartFox.prototype._handleHandShake = function (a) {
    var b = a[SFS2X.Controllers.KEY_ERROR_CODE];
    null == b ? (this.sessionToken = a[SFS2X.Requests.System.HandshakeRequest.KEY_SESSION_TOKEN], this._socketEngine._maxMessageSize = a[SFS2X.Requests.System.HandshakeRequest.KEY_MAX_MESSAGE_SIZE], this._socketEngine._isReconnecting ? this._socketEngine._isReconnecting = !1 : this._dispatchEvent(SFS2X.SFSEvent.CONNECTION, {success: !0})) : (a = {success: !1, errorMessage: SFS2X.ErrorCodes.getErrorMessage(b, a[SFS2X.Controllers.KEY_ERROR_PARAMS]),
        errorCode: b}, this._dispatchEvent(SFS2X.SFSEvent.CONNECTION, a))
};
SFS2X.SmartFox.prototype._handleLogout = function () {
    this._reset(!1)
};
SFS2X.SmartFox.prototype._handleClientDisconnection = function (a) {
    this.isConnected() && this._socketEngine.disconnect(a)
};
(function () {
    var a = !1, b = /xyz/.test(function () {
        xyz
    }) ? /\b_super\b/ : /.*/;
    this.Class = function () {
    };
    Class.extend = function (c) {
        function d() {
            !a && this.init && this.init.apply(this, arguments)
        }

        var e = this.prototype;
        a = !0;
        var f = new this;
        a = !1;
        for (var g in c)f[g] = "function" == typeof c[g] && "function" == typeof e[g] && b.test(c[g]) ? function (a, b) {
            return function () {
                var c = this._super;
                this._super = e[a];
                var d = b.apply(this, arguments);
                this._super = c;
                return d
            }
        }(g, c[g]) : c[g];
        d.prototype = f;
        d.prototype.constructor = d;
        d.extend = arguments.callee;
        return d
    }
})();
var hexcase = 0, b64pad = "";
function hex_md5(a) {
    return rstr2hex(rstr_md5(str2rstr_utf8(a)))
}
function b64_md5(a) {
    return rstr2b64(rstr_md5(str2rstr_utf8(a)))
}
function any_md5(a, b) {
    return rstr2any(rstr_md5(str2rstr_utf8(a)), b)
}
function hex_hmac_md5(a, b) {
    return rstr2hex(rstr_hmac_md5(str2rstr_utf8(a), str2rstr_utf8(b)))
}
function b64_hmac_md5(a, b) {
    return rstr2b64(rstr_hmac_md5(str2rstr_utf8(a), str2rstr_utf8(b)))
}
function any_hmac_md5(a, b, c) {
    return rstr2any(rstr_hmac_md5(str2rstr_utf8(a), str2rstr_utf8(b)), c)
}
function md5_vm_test() {
    return"900150983cd24fb0d6963f7d28e17f72" == hex_md5("abc").toLowerCase()
}
function rstr_md5(a) {
    return binl2rstr(binl_md5(rstr2binl(a), 8 * a.length))
}
function rstr_hmac_md5(a, b) {
    var c = rstr2binl(a);
    16 < c.length && (c = binl_md5(c, 8 * a.length));
    for (var d = Array(16), e = Array(16), f = 0; 16 > f; f++)d[f] = c[f] ^ 909522486, e[f] = c[f] ^ 1549556828;
    c = binl_md5(d.concat(rstr2binl(b)), 512 + 8 * b.length);
    return binl2rstr(binl_md5(e.concat(c), 640))
}
function rstr2hex(a) {
    try {
        hexcase
    } catch (b) {
        hexcase = 0
    }
    for (var c = hexcase ? "0123456789ABCDEF" : "0123456789abcdef", d = "", e, f = 0; f < a.length; f++)e = a.charCodeAt(f), d += c.charAt(e >>> 4 & 15) + c.charAt(e & 15);
    return d
}
function rstr2b64(a) {
    try {
        b64pad
    } catch (b) {
        b64pad = ""
    }
    for (var c = "", d = a.length, e = 0; e < d; e += 3)for (var f = a.charCodeAt(e) << 16 | (e + 1 < d ? a.charCodeAt(e + 1) << 8 : 0) | (e + 2 < d ? a.charCodeAt(e + 2) : 0), g = 0; 4 > g; g++)c = 8 * e + 6 * g > 8 * a.length ? c + b64pad : c + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(f >>> 6 * (3 - g) & 63);
    return c
}
function rstr2any(a, b) {
    var c = b.length, d, e, f, g, h, i = Array(Math.ceil(a.length / 2));
    for (d = 0; d < i.length; d++)i[d] = a.charCodeAt(2 * d) << 8 | a.charCodeAt(2 * d + 1);
    var j = Math.ceil(8 * a.length / (Math.log(b.length) / Math.log(2))), k = Array(j);
    for (e = 0; e < j; e++) {
        h = [];
        for (d = g = 0; d < i.length; d++)if (g = (g << 16) + i[d], f = Math.floor(g / c), g -= f * c, 0 < h.length || 0 < f)h[h.length] = f;
        k[e] = g;
        i = h
    }
    c = "";
    for (d = k.length - 1; 0 <= d; d--)c += b.charAt(k[d]);
    return c
}
function str2rstr_utf8(a) {
    for (var b = "", c = -1, d, e; ++c < a.length;)d = a.charCodeAt(c), e = c + 1 < a.length ? a.charCodeAt(c + 1) : 0, 55296 <= d && (56319 >= d && 56320 <= e && 57343 >= e) && (d = 65536 + ((d & 1023) << 10) + (e & 1023), c++), 127 >= d ? b += String.fromCharCode(d) : 2047 >= d ? b += String.fromCharCode(192 | d >>> 6 & 31, 128 | d & 63) : 65535 >= d ? b += String.fromCharCode(224 | d >>> 12 & 15, 128 | d >>> 6 & 63, 128 | d & 63) : 2097151 >= d && (b += String.fromCharCode(240 | d >>> 18 & 7, 128 | d >>> 12 & 63, 128 | d >>> 6 & 63, 128 | d & 63));
    return b
}
function str2rstr_utf16le(a) {
    for (var b = "", c = 0; c < a.length; c++)b += String.fromCharCode(a.charCodeAt(c) & 255, a.charCodeAt(c) >>> 8 & 255);
    return b
}
function str2rstr_utf16be(a) {
    for (var b = "", c = 0; c < a.length; c++)b += String.fromCharCode(a.charCodeAt(c) >>> 8 & 255, a.charCodeAt(c) & 255);
    return b
}
function rstr2binl(a) {
    for (var b = Array(a.length >> 2), c = 0; c < b.length; c++)b[c] = 0;
    for (c = 0; c < 8 * a.length; c += 8)b[c >> 5] |= (a.charCodeAt(c / 8) & 255) << c % 32;
    return b
}
function binl2rstr(a) {
    for (var b = "", c = 0; c < 32 * a.length; c += 8)b += String.fromCharCode(a[c >> 5] >>> c % 32 & 255);
    return b
}
function binl_md5(a, b) {
    a[b >> 5] |= 128 << b % 32;
    a[(b + 64 >>> 9 << 4) + 14] = b;
    for (var c = 1732584193, d = -271733879, e = -1732584194, f = 271733878, g = 0; g < a.length; g += 16)var h = c, i = d, j = e, k = f, c = md5_ff(c, d, e, f, a[g + 0], 7, -680876936), f = md5_ff(f, c, d, e, a[g + 1], 12, -389564586), e = md5_ff(e, f, c, d, a[g + 2], 17, 606105819), d = md5_ff(d, e, f, c, a[g + 3], 22, -1044525330), c = md5_ff(c, d, e, f, a[g + 4], 7, -176418897), f = md5_ff(f, c, d, e, a[g + 5], 12, 1200080426), e = md5_ff(e, f, c, d, a[g + 6], 17, -1473231341), d = md5_ff(d, e, f, c, a[g + 7], 22, -45705983), c = md5_ff(c, d, e, f, a[g + 8], 7,
        1770035416), f = md5_ff(f, c, d, e, a[g + 9], 12, -1958414417), e = md5_ff(e, f, c, d, a[g + 10], 17, -42063), d = md5_ff(d, e, f, c, a[g + 11], 22, -1990404162), c = md5_ff(c, d, e, f, a[g + 12], 7, 1804603682), f = md5_ff(f, c, d, e, a[g + 13], 12, -40341101), e = md5_ff(e, f, c, d, a[g + 14], 17, -1502002290), d = md5_ff(d, e, f, c, a[g + 15], 22, 1236535329), c = md5_gg(c, d, e, f, a[g + 1], 5, -165796510), f = md5_gg(f, c, d, e, a[g + 6], 9, -1069501632), e = md5_gg(e, f, c, d, a[g + 11], 14, 643717713), d = md5_gg(d, e, f, c, a[g + 0], 20, -373897302), c = md5_gg(c, d, e, f, a[g + 5], 5, -701558691), f = md5_gg(f, c, d, e, a[g +
        10], 9, 38016083), e = md5_gg(e, f, c, d, a[g + 15], 14, -660478335), d = md5_gg(d, e, f, c, a[g + 4], 20, -405537848), c = md5_gg(c, d, e, f, a[g + 9], 5, 568446438), f = md5_gg(f, c, d, e, a[g + 14], 9, -1019803690), e = md5_gg(e, f, c, d, a[g + 3], 14, -187363961), d = md5_gg(d, e, f, c, a[g + 8], 20, 1163531501), c = md5_gg(c, d, e, f, a[g + 13], 5, -1444681467), f = md5_gg(f, c, d, e, a[g + 2], 9, -51403784), e = md5_gg(e, f, c, d, a[g + 7], 14, 1735328473), d = md5_gg(d, e, f, c, a[g + 12], 20, -1926607734), c = md5_hh(c, d, e, f, a[g + 5], 4, -378558), f = md5_hh(f, c, d, e, a[g + 8], 11, -2022574463), e = md5_hh(e, f, c, d, a[g +
        11], 16, 1839030562), d = md5_hh(d, e, f, c, a[g + 14], 23, -35309556), c = md5_hh(c, d, e, f, a[g + 1], 4, -1530992060), f = md5_hh(f, c, d, e, a[g + 4], 11, 1272893353), e = md5_hh(e, f, c, d, a[g + 7], 16, -155497632), d = md5_hh(d, e, f, c, a[g + 10], 23, -1094730640), c = md5_hh(c, d, e, f, a[g + 13], 4, 681279174), f = md5_hh(f, c, d, e, a[g + 0], 11, -358537222), e = md5_hh(e, f, c, d, a[g + 3], 16, -722521979), d = md5_hh(d, e, f, c, a[g + 6], 23, 76029189), c = md5_hh(c, d, e, f, a[g + 9], 4, -640364487), f = md5_hh(f, c, d, e, a[g + 12], 11, -421815835), e = md5_hh(e, f, c, d, a[g + 15], 16, 530742520), d = md5_hh(d, e, f,
        c, a[g + 2], 23, -995338651), c = md5_ii(c, d, e, f, a[g + 0], 6, -198630844), f = md5_ii(f, c, d, e, a[g + 7], 10, 1126891415), e = md5_ii(e, f, c, d, a[g + 14], 15, -1416354905), d = md5_ii(d, e, f, c, a[g + 5], 21, -57434055), c = md5_ii(c, d, e, f, a[g + 12], 6, 1700485571), f = md5_ii(f, c, d, e, a[g + 3], 10, -1894986606), e = md5_ii(e, f, c, d, a[g + 10], 15, -1051523), d = md5_ii(d, e, f, c, a[g + 1], 21, -2054922799), c = md5_ii(c, d, e, f, a[g + 8], 6, 1873313359), f = md5_ii(f, c, d, e, a[g + 15], 10, -30611744), e = md5_ii(e, f, c, d, a[g + 6], 15, -1560198380), d = md5_ii(d, e, f, c, a[g + 13], 21, 1309151649), c = md5_ii(c,
        d, e, f, a[g + 4], 6, -145523070), f = md5_ii(f, c, d, e, a[g + 11], 10, -1120210379), e = md5_ii(e, f, c, d, a[g + 2], 15, 718787259), d = md5_ii(d, e, f, c, a[g + 9], 21, -343485551), c = safe_add(c, h), d = safe_add(d, i), e = safe_add(e, j), f = safe_add(f, k);
    return[c, d, e, f]
}
function md5_cmn(a, b, c, d, e, f) {
    return safe_add(bit_rol(safe_add(safe_add(b, a), safe_add(d, f)), e), c)
}
function md5_ff(a, b, c, d, e, f, g) {
    return md5_cmn(b & c | ~b & d, a, b, e, f, g)
}
function md5_gg(a, b, c, d, e, f, g) {
    return md5_cmn(b & d | c & ~d, a, b, e, f, g)
}
function md5_hh(a, b, c, d, e, f, g) {
    return md5_cmn(b ^ c ^ d, a, b, e, f, g)
}
function md5_ii(a, b, c, d, e, f, g) {
    return md5_cmn(c ^ (b | ~d), a, b, e, f, g)
}
function safe_add(a, b) {
    var c = (a & 65535) + (b & 65535);
    return(a >> 16) + (b >> 16) + (c >> 16) << 16 | c & 65535
}
function bit_rol(a, b) {
    return a << b | a >>> 32 - b
}
SFS2X.Utils = {};
SFS2X.Utils.md5_crypt = function (a, b) {
    "undefined" != typeof VarType && (a = VarType.toStr(a), b = VarType.toStr(b));
    var c = b64pad;
    b64pad = "";
    var d = chrsz;
    chrsz = 8;
    "$1$" == b.substr(0, 3) && (b = b.substr(3));
    var e = b.indexOf("$");
    if (0 > e || 8 < e)e = 8;
    for (var b = b.substr(0, e), f = a + "$1$" + b, g = str_md5(a + b + a), e = a.length; 0 < e; e -= 16)f = 16 <= e ? f + g : f + g.substr(0, e);
    for (e = a.length; 0 != e; e >>= 1)f = 0 != (e & 1) ? f + String.fromCharCode(0) : f + a.charAt(0);
    for (var h = "$1$" + b + "$", g = str_md5(f), e = 0; 1E3 > e; e++)f = "", f = 0 != (e & 1) ? f + a : f + g, 0 != e % 3 && (f += b), 0 != e % 7 && (f +=
        a), f = 0 != (e & 1) ? f + g : f + a, g = str_md5(f);
    g += g.charAt(5);
    for (e = 0; 5 > e; e++)f = g.charCodeAt(e) << 16 | g.charCodeAt(e + 6) << 8 | g.charCodeAt(e + 12), h += md5_to64(f, 4);
    f = g.charCodeAt(11);
    h += md5_to64(f, 2);
    b64pad = c;
    chrsz = d;
    return h
};
SFS2X.Utils.ClientDisconnectionReason = {IDLE: "idle", KICK: "kick", BAN: "ban", MANUAL: "manual", UNKNOWN: "unknown"};
SFS2X.Utils.ClientDisconnectionReason.getReason = function (a) {
    switch (a) {
        case 0:
            return this.IDLE;
        case 1:
            return this.KICK;
        case 2:
            return this.BAN;
        case 3:
            return this.MANUAL;
        case 4:
            return this.UNKNOWN
    }
};
SFS2X.Utils.ArrayUtil = {};
SFS2X.Utils.ArrayUtil.objToArray = function (a) {
    var b = [], c;
    for (c in a)a.hasOwnProperty(c) && b.push(a[c]);
    return b
};
SFS2X.Utils.ArrayUtil.removeItem = function (a, b) {
    var c = a.indexOf(b);
    -1 < c && a.splice(c, 1)
};
SFS2X.Utils.HashTable = function (a) {
    this.length = 0;
    this.items = {};
    for (var b in a)a.hasOwnProperty(b) && (this.items[b] = a[b], this.length++)
};
SFS2X.Utils.HashTable.prototype.setItem = function (a, b) {
    var c = void 0;
    this.hasItem(a) ? c = this.items[a] : this.length++;
    this.items[a] = b;
    return c
};
SFS2X.Utils.HashTable.prototype.getItem = function (a) {
    return this.hasItem(a) ? this.items[a] : void 0
};
SFS2X.Utils.HashTable.prototype.hasItem = function (a) {
    return this.items.hasOwnProperty(a)
};
SFS2X.Utils.HashTable.prototype.removeItem = function (a) {
    if (this.hasItem(a))return previous = this.items[a], this.length--, delete this.items[a], previous
};
SFS2X.Utils.HashTable.prototype.keys = function () {
    var a = [], b;
    for (b in this.items)this.hasItem(b) && a.push(b);
    return a
};
SFS2X.Utils.HashTable.prototype.values = function () {
    var a = [], b;
    for (b in this.items)this.hasItem(b) && a.push(this.items[b]);
    return a
};
SFS2X.Utils.HashTable.prototype.each = function (a) {
    for (var b in this.items)this.hasItem(b) && a(b, this.items[b])
};
SFS2X.Utils.HashTable.prototype.clear = function () {
    this.items = {};
    this.length = 0
};
SFS2X.Utils.LagMonitor = function (a, b, c) {
    if (null == b || 1 > b)b = 4;
    if (null == c || 1 > c)c = 10;
    this._sfs = a;
    this._valueQueue = [];
    this._interval = b;
    this._queueSize = c;
    this._thread = null;
    this._lastReqTime = -1
};
SFS2X.Utils.LagMonitor.prototype.start = function () {
    !this.isRunning() && null != this._sfs && (this._thread = setInterval(this._threadRunner, 1E3 * this._interval, this))
};
SFS2X.Utils.LagMonitor.prototype.stop = function () {
    this.isRunning() && (clearInterval(this._thread), this._thread = null, this._valueQueue = [])
};
SFS2X.Utils.LagMonitor.prototype.destroy = function () {
    this.stop();
    this._sfs = null
};
SFS2X.Utils.LagMonitor.prototype.isRunning = function () {
    return null != this._thread
};
SFS2X.Utils.LagMonitor.prototype.getLastPingTime = function () {
    return 0 < this._valueQueue.length ? this._valueQueue[this._valueQueue.length - 1] : 0
};
SFS2X.Utils.LagMonitor.prototype._threadRunner = function (a) {
    a._lastReqTime = (new Date).getTime();
    a._sfs.send(new SFS2X.Requests.System.PingPongRequest)
};
SFS2X.Utils.LagMonitor.prototype._onPingPong = function () {
    var a = (new Date).getTime() - this._lastReqTime;
    this._valueQueue.length >= this._queueSize && this._valueQueue.shift();
    this._valueQueue.push(a);
    return this._getAveragePingTime()
};
SFS2X.Utils.LagMonitor.prototype._getAveragePingTime = function () {
    if (0 == this._valueQueue.length)return 0;
    for (var a = 0, b = 0; b < this._valueQueue.length; b++)a += this._valueQueue[b];
    return a / this._valueQueue.length
};
SFS2X.Utils.BuddyOnlineState = {ONLINE: 0, OFFLINE: 1, LEFT_THE_SERVER: 2};
SFS2X.Controllers = {};
SFS2X.Controllers.CONTROLLER_ID = "c";
SFS2X.Controllers.ACTION_ID = "a";
SFS2X.Controllers.PARAM_ID = "p";
SFS2X.Controllers.KEY_ERROR_CODE = "ec";
SFS2X.Controllers.KEY_ERROR_PARAMS = "ep";
SFS2X.Controllers.ROOM_PARAM = "r";
SFS2X.Controllers.USER_PARAM = "u";
SFS2X.Controllers.USER_COUNT_PARAM = "uc";
SFS2X.Controllers.SPECT_COUNT_PARAM = "sc";
SFS2X.Controllers.SystemController = function (a) {
    this._sfs = a;
    this._id = 0;
    this._requestHandlers = {};
    this._initRequestHandlers();
    this._log = SFS2X.Logger
};
SFS2X.Controllers.SystemController.prototype.getId = function () {
    return this._id
};
SFS2X.Controllers.SystemController.prototype.handleMessage = function (a, b) {
    this._sfs.debug && this._log.info("IN < " + this._getEvtName(b));
    var c = this._requestHandlers[b];
    if (null != c)this[c](a); else this._log.warn("Unknown message id: " + a.id)
};
SFS2X.Controllers.SystemController.prototype._initRequestHandlers = function () {
    this._requestHandlers[SFS2X.Requests.Handshake] = "_fnHandshake";
    this._requestHandlers[SFS2X.Requests.Login] = "_fnLogin";
    this._requestHandlers[SFS2X.Requests.Logout] = "_fnLogout";
    this._requestHandlers[SFS2X.Requests.JoinRoom] = "_fnJoinRoom";
    this._requestHandlers[SFS2X.Requests.CreateRoom] = "_fnCreateRoom";
    this._requestHandlers[SFS2X.Requests.ChangeRoomName] = "_fnChangeRoomName";
    this._requestHandlers[SFS2X.Requests.ChangeRoomPassword] =
        "_fnChangeRoomPassword";
    this._requestHandlers[SFS2X.Requests.ChangeRoomCapacity] = "_fnChangeRoomCapacity";
    this._requestHandlers[SFS2X.Requests.GenericMessage] = "_fnGenericMessage";
    this._requestHandlers[SFS2X.Requests.SetRoomVariables] = "_fnSetRoomVariables";
    this._requestHandlers[SFS2X.Requests.SetUserVariables] = "_fnSetUserVariables";
    this._requestHandlers[SFS2X.Requests.SubscribeRoomGroup] = "_fnSubscribeRoomGroup";
    this._requestHandlers[SFS2X.Requests.UnsubscribeRoomGroup] = "_fnUnsubscribeRoomGroup";
    this._requestHandlers[SFS2X.Requests.SpectatorToPlayer] =
        "_fnSpectatorToPlayer";
    this._requestHandlers[SFS2X.Requests.PlayerToSpectator] = "_fnPlayerToSpectator";
    this._requestHandlers[SFS2X.Requests.InitBuddyList] = "_fnInitBuddyList";
    this._requestHandlers[SFS2X.Requests.AddBuddy] = "_fnAddBuddy";
    this._requestHandlers[SFS2X.Requests.RemoveBuddy] = "_fnRemoveBuddy";
    this._requestHandlers[SFS2X.Requests.BlockBuddy] = "_fnBlockBuddy";
    this._requestHandlers[SFS2X.Requests.GoOnline] = "_fnGoOnline";
    this._requestHandlers[SFS2X.Requests.SetBuddyVariables] = "_fnSetBuddyVariables";
    this._requestHandlers[SFS2X.Requests.FindRooms] = "_fnFindRooms";
    this._requestHandlers[SFS2X.Requests.FindUsers] = "_fnFindUsers";
    this._requestHandlers[SFS2X.Requests.InviteUsers] = "_fnInviteUsers";
    this._requestHandlers[SFS2X.Requests.InvitationReply] = "_fnInvitationReply";
    this._requestHandlers[SFS2X.Requests.QuickJoinGame] = "_fnQuickJoinGame";
    this._requestHandlers[SFS2X.Requests.PingPong] = "_fnPingPong";
    this._requestHandlers[1E3] = "_fnUserEnterRoom";
    this._requestHandlers[1001] = "_fnUserCountChange";
    this._requestHandlers[1002] =
        "_fnUserLost";
    this._requestHandlers[1003] = "_fnRoomLost";
    this._requestHandlers[1004] = "_fnUserExitRoom";
    this._requestHandlers[1005] = "_fnClientDisconnection"
};
SFS2X.Controllers.SystemController.prototype._getEvtName = function (a) {
    return this._requestHandlers[a].substr(3)
};
SFS2X.Controllers.SystemController.prototype._fnHandshake = function (a) {
    this._sfs._handleHandShake(a)
};
SFS2X.Controllers.SystemController.prototype._fnLogin = function (a) {
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        this._populateRoomList(a[SFS2X.Requests.System.LoginRequest.KEY_ROOMLIST]);
        this._sfs.mySelf = new SFS2X.Entities.SFSUser(a[SFS2X.Requests.System.LoginRequest.KEY_ID], a[SFS2X.Requests.System.LoginRequest.KEY_USER_NAME], !0);
        this._sfs.mySelf._setUserManager(this._sfs.userManager);
        this._sfs.mySelf.privilegeId = a[SFS2X.Requests.System.LoginRequest.KEY_PRIVILEGE_ID];
        this._sfs.userManager._addUser(this._sfs.mySelf);
        this._sfs._socketEngine.reconnectionSeconds = a[SFS2X.Requests.System.LoginRequest.KEY_RECONNECTION_SECONDS];
        var b = {};
        b.zone = a[SFS2X.Requests.System.LoginRequest.KEY_ZONE_NAME];
        b.user = this._sfs.mySelf;
        b.data = a[SFS2X.Requests.System.LoginRequest.KEY_PARAMS];
        this._sfs._dispatchEvent(SFS2X.SFSEvent.LOGIN, b)
    } else b = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(b, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), this._sfs._dispatchEvent(SFS2X.SFSEvent.LOGIN_ERROR, {errorMessage: a, errorCode: b})
};
SFS2X.Controllers.SystemController.prototype._fnLogout = function (a) {
    this._sfs._handleLogout();
    var b = {};
    b.zone = a[SFS2X.Requests.System.LogoutRequest.KEY_ZONE_NAME];
    this._sfs._dispatchEvent(SFS2X.SFSEvent.LOGOUT, b)
};
SFS2X.Controllers.SystemController.prototype._fnJoinRoom = function (a) {
    var b = this._sfs.roomManager, c = {};
    this._sfs._isJoining = !1;
    var d = a[SFS2X.Controllers.KEY_ERROR_CODE];
    if (null == d) {
        d = a[SFS2X.Requests.System.JoinRoomRequest.KEY_USER_LIST];
        a = SFS2X.Entities.SFSRoom.fromArray(a[SFS2X.Requests.System.JoinRoomRequest.KEY_ROOM]);
        a._setRoomManager(b);
        a = b._replaceRoom(a, b.containsGroup(a.groupId));
        for (b = 0; b < d.length; b++) {
            var e = d[b], f = this._getOrCreateUser(e, !0, a);
            f._setPlayerId(e[3], a);
            a._addUser(f)
        }
        a.isJoined = !0;
        this._sfs.lastJoinedRoom = a;
        c.room = a;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_JOIN, c)
    } else a = SFS2X.ErrorCodes.getErrorMessage(d, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), c.errorMessage = a, c.errorCode = d, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_JOIN_ERROR, c)
};
SFS2X.Controllers.SystemController.prototype._fnCreateRoom = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = this._sfs.roomManager, a = SFS2X.Entities.SFSRoom.fromArray(a[SFS2X.Requests.System.CreateRoomRequest.KEY_ROOM]);
        a._setRoomManager = c;
        c._addRoom(a);
        b.room = a;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_ADD, b)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_CREATION_ERROR,
        b)
};
SFS2X.Controllers.SystemController.prototype._fnChangeRoomName = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = this._sfs.roomManager.getRoomById(a[SFS2X.Requests.System.ChangeRoomNameRequest.KEY_ROOM]);
        null != c ? (b.oldName = c.name, this._sfs.roomManager._changeRoomName(c, a[SFS2X.Requests.System.ChangeRoomNameRequest.KEY_NAME]), b.room = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_NAME_CHANGE, b)) : this._log.warn("RoomNameChange event, unknown Room id: " + rId)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a =
        SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_NAME_CHANGE_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnChangeRoomPassword = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = this._sfs.roomManager.getRoomById(a[SFS2X.Requests.System.ChangeRoomNameRequest.KEY_ROOM]);
        null != c ? (this._sfs.roomManager._changeRoomPasswordState(c, a[SFS2X.Requests.System.ChangeRoomPasswordStateRequest.KEY_PASS]), b.room = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE, b)) : this._log.warn("RoomPasswordChange event, unknown Room id: " + rId)
    } else c =
        a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_PASSWORD_STATE_CHANGE_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnChangeRoomCapacity = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = this._sfs.roomManager.getRoomById(a[SFS2X.Requests.System.ChangeRoomNameRequest.KEY_ROOM]);
        null != c ? (this._sfs.roomManager._changeRoomCapacity(c, a[SFS2X.Requests.System.ChangeRoomCapacityRequest.KEY_USER_SIZE], a[SFS2X.Requests.System.ChangeRoomCapacityRequest.KEY_SPEC_SIZE]), b.room = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE, b)) : this._log.warn("RoomPasswordChange event, unknown Room id: " +
            rId)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_CAPACITY_CHANGE_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnGenericMessage = function (a) {
    switch (a[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE_TYPE]) {
        case SFS2X.Requests.GenericMessageType.PUBLIC_MSG:
            this._handlePublicMessage(a);
            break;
        case SFS2X.Requests.GenericMessageType.PRIVATE_MSG:
            this._handlePrivateMessage(a);
            break;
        case SFS2X.Requests.GenericMessageType.BUDDY_MSG:
            this._handleBuddyMessage(a);
            break;
        case SFS2X.Requests.GenericMessageType.MODERATOR_MSG:
            this._handleModMessage(a);
            break;
        case SFS2X.Requests.GenericMessageType.ADMING_MSG:
            this._handleAdminMessage(a);
            break;
        case SFS2X.Requests.GenericMessageType.OBJECT_MSG:
            this._handleObjectMessage(a)
    }
};
SFS2X.Controllers.SystemController.prototype._handlePublicMessage = function (a) {
    var b = {}, c = a[SFS2X.Requests.System.GenericMessageRequest.KEY_ROOM_ID], d = this._sfs.roomManager.getRoomById(c);
    null != d ? (b.room = d, b.sender = this._sfs.userManager.getUserById(a[SFS2X.Requests.System.GenericMessageRequest.KEY_USER_ID]), b.message = a[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE], b.data = a[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS], this._sfs._dispatchEvent(SFS2X.SFSEvent.PUBLIC_MESSAGE,
        b)) : this._log.warn("Unexpected, public message target Room doesn't exist; Room id: " + c)
};
SFS2X.Controllers.SystemController.prototype._handlePrivateMessage = function (a) {
    var b = {}, c = this._sfs.userManager.getUserById(a[SFS2X.Requests.System.GenericMessageRequest.KEY_USER_ID]);
    if (null == c) {
        if (null == a[SFS2X.Requests.System.GenericMessageRequest.KEY_SENDER_DATA]) {
            this._log.warn("Unexpected, private message has no sender details");
            return
        }
        c = SFS2X.Entities.SFSUser.fromArray(a[SFS2X.Requests.System.GenericMessageRequest.KEY_SENDER_DATA])
    }
    b.sender = c;
    b.message = a[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE];
    b.data = a[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS];
    this._sfs._dispatchEvent(SFS2X.SFSEvent.PRIVATE_MESSAGE, b)
};
SFS2X.Controllers.SystemController.prototype._handleBuddyMessage = function (a) {
    var b = {}, c = a[SFS2X.Requests.System.GenericMessageRequest.KEY_USER_ID], d = this._sfs.buddyManager.getBuddyById(c);
    b.isItMe = this._sfs.mySelf.id == c;
    b.buddy = d;
    b.message = a[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE];
    b.data = a[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS];
    this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_MESSAGE, b)
};
SFS2X.Controllers.SystemController.prototype._handleModMessage = function (a) {
    var b = {};
    b.sender = SFS2X.Entities.SFSUser.fromArray(a[SFS2X.Requests.System.GenericMessageRequest.KEY_SENDER_DATA]);
    b.message = a[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE];
    b.data = a[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS];
    this._sfs._dispatchEvent(SFS2X.SFSEvent.MODERATOR_MESSAGE, b)
};
SFS2X.Controllers.SystemController.prototype._handleAdminMessage = function (a) {
    var b = {};
    b.sender = SFS2X.Entities.SFSUser.fromArray(a[SFS2X.Requests.System.GenericMessageRequest.KEY_SENDER_DATA]);
    b.message = a[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE];
    b.data = a[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS];
    this._sfs._dispatchEvent(SFS2X.SFSEvent.ADMIN_MESSAGE, b)
};
SFS2X.Controllers.SystemController.prototype._handleObjectMessage = function (a) {
    var b = {};
    b.sender = this._sfs.userManager.getUserById(a[SFS2X.Requests.System.GenericMessageRequest.KEY_USER_ID]);
    b.message = a[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS];
    this._sfs._dispatchEvent(SFS2X.SFSEvent.OBJECT_MESSAGE, b)
};
SFS2X.Controllers.SystemController.prototype._fnSetRoomVariables = function (a) {
    var b = a[SFS2X.Requests.System.SetRoomVariablesRequest.KEY_VAR_ROOM], c = a[SFS2X.Requests.System.SetRoomVariablesRequest.KEY_VAR_LIST], a = this._sfs.roomManager.getRoomById(b), d = [];
    if (null != a) {
        for (b = 0; b < c.length; b++) {
            var e = SFS2X.Entities.Variables.SFSRoomVariable.fromArray(c[b]);
            a._setVariable(e);
            d.push(e.name)
        }
        c = {};
        c.changedVars = d;
        c.room = a;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_VARIABLES_UPDATE, c)
    } else this._log.warn("RoomVariablesUpdate event, unknown Room id: " +
        b)
};
SFS2X.Controllers.SystemController.prototype._fnSetUserVariables = function (a) {
    var b = a[SFS2X.Requests.System.SetUserVariablesRequest.KEY_USER], c = a[SFS2X.Requests.System.SetUserVariablesRequest.KEY_VAR_LIST], a = this._sfs.userManager.getUserById(b), d = [];
    if (null != a) {
        for (b = 0; b < c.length; b++) {
            var e = SFS2X.Entities.Variables.SFSUserVariable.fromArray(c[b]);
            a._setVariable(e);
            d.push(e.name)
        }
        c = {};
        c.changedVars = d;
        c.user = a;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.USER_VARIABLES_UPDATE, c)
    } else this._log.warn("UserVariablesUpdate event, unknown User id: " + b)
};
SFS2X.Controllers.SystemController.prototype._fnSubscribeRoomGroup = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = a[SFS2X.Requests.System.SubscribeRoomGroupRequest.KEY_GROUP_ID], a = a[SFS2X.Requests.System.SubscribeRoomGroupRequest.KEY_ROOM_LIST];
        this._sfs.roomManager.containsGroup(c) && this._log.warn("Subscribe Group error: Group '" + c + "' already subscribed");
        this._populateRoomList(a);
        b.groupId = c;
        b.newRooms = this._sfs.roomManager.getRoomListFromGroup(c);
        this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE,
            b)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_GROUP_SUBSCRIBE_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnUnsubscribeRoomGroup = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = a[SFS2X.Requests.System.UnsubscribeRoomGroupRequest.KEY_GROUP_ID];
        this._sfs.roomManager.containsGroup(c) || this._log.warn("Unsubscribe Group error: Group '" + c + "' not found (maybe never subscribed, or the Room Manager doesn't contain Rooms belonging to that Group)");
        this._sfs.roomManager._removeGroup(c);
        b.groupId = c;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE,
            b)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_GROUP_UNSUBSCRIBE_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnSpectatorToPlayer = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = a[SFS2X.Requests.System.SpectatorToPlayerRequest.KEY_ROOM_ID], d = a[SFS2X.Requests.System.SpectatorToPlayerRequest.KEY_USER_ID], a = a[SFS2X.Requests.System.SpectatorToPlayerRequest.KEY_PLAYER_ID], e = this._sfs.userManager.getUserById(d), f = this._sfs.roomManager.getRoomById(c);
        null != f ? null != e ? e.isJoinedInRoom(f) ? (e._setPlayerId(a, f), b.room = f, b.user = e, b.playerId = a, this._sfs._dispatchEvent(SFS2X.SFSEvent.SPECTATOR_TO_PLAYER,
            b)) : this._log.warn("SpectatorToPlayer event, user " + e + " not joined in Room ", f) : this._log.warn("SpectatorToPlayer event, unknown User id: " + d) : this._log.warn("SpectatorToPlayer event, unknown Room id: " + c)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], d = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = d, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.SPECTATOR_TO_PLAYER_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnPlayerToSpectator = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = a[SFS2X.Requests.System.PlayerToSpectatorRequest.KEY_ROOM_ID], a = a[SFS2X.Requests.System.PlayerToSpectatorRequest.KEY_USER_ID], d = this._sfs.userManager.getUserById(a), e = this._sfs.roomManager.getRoomById(c);
        null != e ? null != d ? d.isJoinedInRoom(e) ? (d._setPlayerId(-1, e), b.room = e, b.user = d, this._sfs._dispatchEvent(SFS2X.SFSEvent.PLAYER_TO_SPECTATOR, b)) : this._log.warn("PlayerToSpectator event, user " +
            d + " not joined in Room ", e) : this._log.warn("PlayerToSpectator event, unknown User id: " + a) : this._log.warn("PlayerToSpectator event, unknown Room id: " + c)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.PLAYER_TO_SPECTATOR_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnFindRooms = function (a) {
    for (var b = {}, a = a[SFS2X.Requests.System.FindRoomsRequest.KEY_FILTERED_ROOMS], c = [], d = 0; d < a.length; d++)c.push(SFS2X.Entities.SFSRoom.fromArray(a[d]));
    b.rooms = c;
    this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_FIND_RESULT, b)
};
SFS2X.Controllers.SystemController.prototype._fnFindUsers = function (a) {
    for (var b = {}, a = a[SFS2X.Requests.System.FindUsersRequest.KEY_FILTERED_USERS], c = [], d = this._sfs.mySelf, e = 0; e < a.length; e++) {
        var f = SFS2X.Entities.SFSUser.fromArray(a[e]);
        f.id == d.id && (f = d);
        c.push(f)
    }
    b.users = c;
    this._sfs._dispatchEvent(SFS2X.SFSEvent.USER_FIND_RESULT, b)
};
SFS2X.Controllers.SystemController.prototype._fnInviteUsers = function (a) {
    var b = {}, c = null, c = null != a[SFS2X.Requests.Game.InviteUsersRequest.KEY_USER_ID] ? this._sfs.userManager.getUserById(a[SFS2X.Requests.Game.InviteUsersRequest.KEY_USER_ID]) : SFS2X.Entities.SFSUser.fromArray(a[SFS2X.Requests.Game.InviteUsersRequest.KEY_USER]), d = a[SFS2X.Requests.Game.InviteUsersRequest.KEY_INVITATION_ID], a = new SFS2X.Entities.Invitation.SFSInvitation(c, sfs.mySelf, a[SFS2X.Requests.Game.InviteUsersRequest.KEY_TIME], a[SFS2X.Requests.Game.InviteUsersRequest.KEY_PARAMS]);
    a.id = d;
    b.invitation = a;
    this._sfs._dispatchEvent(SFS2X.SFSEvent.INVITATION, b)
};
SFS2X.Controllers.SystemController.prototype._fnInvitationReply = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = null, c = null != a[SFS2X.Requests.Game.InviteUsersRequest.KEY_USER_ID] ? this._sfs.userManager.getUserById(a[SFS2X.Requests.Game.InviteUsersRequest.KEY_USER_ID]) : SFS2X.Entities.SFSUser.fromArray(a[SFS2X.Requests.Game.InviteUsersRequest.KEY_USER]), d = a[SFS2X.Requests.Game.InviteUsersRequest.KEY_REPLY_ID], a = a[SFS2X.Requests.Game.InviteUsersRequest.KEY_PARAMS];
        b.invitee = c;
        b.reply = d;
        b.data = a;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.INVITATION_REPLY, b)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSEvent.INVITATION_REPLY_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnQuickJoinGame = function (a) {
    if (null != a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var b = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(b, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), c = {};
        c.errorMessage = a;
        c.errorCode = b;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_JOIN_ERROR, c)
    }
};
SFS2X.Controllers.SystemController.prototype._fnPingPong = function () {
    var a = this._sfs._lagMonitor._onPingPong(), b = {};
    b.lagValue = a;
    this._sfs._dispatchEvent(SFS2X.SFSEvent.PING_PONG, b)
};
SFS2X.Controllers.SystemController.prototype._fnUserEnterRoom = function (a) {
    var b = this._sfs.roomManager.getRoomById(a[SFS2X.Controllers.ROOM_PARAM]);
    if (null != b) {
        a = this._getOrCreateUser(a[SFS2X.Controllers.USER_PARAM], !0, b);
        b._addUser(a);
        var c = {};
        c.user = a;
        c.room = b;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.USER_ENTER_ROOM, c)
    }
};
SFS2X.Controllers.SystemController.prototype._fnUserCountChange = function (a) {
    var b = this._sfs.roomManager.getRoomById(a[SFS2X.Controllers.ROOM_PARAM]);
    if (null != b) {
        var c = a[SFS2X.Controllers.USER_COUNT_PARAM], d = 0;
        null != a.sc && (d = a[SFS2X.Controllers.SPECT_COUNT_PARAM]);
        b._userCount = c;
        b._specCount = d;
        a = {};
        a.room = b;
        a.uCount = c;
        a.sCount = d;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.USER_COUNT_CHANGE, a)
    }
};
SFS2X.Controllers.SystemController.prototype._fnUserLost = function (a) {
    a = this._sfs.userManager.getUserById(a[SFS2X.Controllers.USER_PARAM]);
    if (null != a) {
        var b = this._sfs.roomManager.getUserRooms(a);
        this._sfs.roomManager._removeUser(a);
        this._sfs.userManager._removeUser(a);
        for (var c in b) {
            var d = {};
            d.user = a;
            d.room = b[c];
            this._sfs._dispatchEvent(SFS2X.SFSEvent.USER_EXIT_ROOM, d)
        }
    }
};
SFS2X.Controllers.SystemController.prototype._fnRoomLost = function (a) {
    var a = this._sfs.roomManager.getRoomById(a[SFS2X.Controllers.ROOM_PARAM]), b = this._sfs.userManager;
    if (null != a) {
        this._sfs.roomManager._removeRoom(a);
        var c = a.getUserList(), d;
        for (d in c)b._removeUser(c[d]);
        d = {};
        d.room = a;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.ROOM_REMOVE, d)
    }
};
SFS2X.Controllers.SystemController.prototype._fnUserExitRoom = function (a) {
    var b = this._sfs.roomManager.getRoomById(a[SFS2X.Controllers.ROOM_PARAM]), a = this._sfs.userManager.getUserById(a[SFS2X.Controllers.USER_PARAM]);
    if (null != b && null != a) {
        b._removeUser(a);
        this._sfs.userManager._removeUser(a);
        a.isItMe && b.isJoined && (b.isJoined = !1, 0 == this._sfs.roomManager.getJoinedRooms().length && (this._sfs.lastJoinedRoom = null), b._isManaged || this._sfs.roomManager._removeRoom(b));
        var c = {};
        c.user = a;
        c.room = b;
        this._sfs._dispatchEvent(SFS2X.SFSEvent.USER_EXIT_ROOM,
            c)
    } else this._log.debug("Failed to handle UserExit event. Room: " + b + ", User: " + a)
};
SFS2X.Controllers.SystemController.prototype._fnClientDisconnection = function (a) {
    this._sfs._handleClientDisconnection(SFS2X.Utils.ClientDisconnectionReason.getReason(a.dr))
};
SFS2X.Controllers.SystemController.prototype._fnInitBuddyList = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = a[SFS2X.Requests.BuddyList.InitBuddyListRequest.KEY_BLIST], d = a[SFS2X.Requests.BuddyList.InitBuddyListRequest.KEY_MY_VARS], e = a[SFS2X.Requests.BuddyList.InitBuddyListRequest.KEY_BUDDY_STATES];
        this._sfs.buddyManager._clearAll();
        for (a = 0; a < c.length; a++) {
            var f = SFS2X.Entities.SFSBuddy.fromArray(c[a]);
            this._sfs.buddyManager._addBuddy(f)
        }
        null != e && this._sfs.buddyManager._setBuddyStates(e);
        c = [];
        for (a = 0; a < d.length; a++)e = SFS2X.Entities.Variables.SFSBuddyVariable.fromArray(d[a]), c.push(e);
        this._sfs.buddyManager._setMyVariables(c);
        this._sfs.buddyManager._setInited();
        b.buddyList = this._sfs.buddyManager.getBuddyList();
        b.myVariables = this._sfs.buddyManager.getMyVariables();
        this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_LIST_INIT, b)
    } else d = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(d, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = d, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_ERROR,
        b)
};
SFS2X.Controllers.SystemController.prototype._fnAddBuddy = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = SFS2X.Entities.SFSBuddy.fromArray(a[SFS2X.Requests.BuddyList.AddBuddyRequest.KEY_BUDDY_NAME]);
        this._sfs.buddyManager._addBuddy(c);
        b.buddy = c;
        this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_ADD, b)
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnRemoveBuddy = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = a[SFS2X.Requests.BuddyList.RemoveBuddyRequest.KEY_BUDDY_NAME], a = this._sfs.buddyManager._removeBuddyByName(c);
        null != a ? (b.buddy = a, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_REMOVE, b)) : this._log.warn("Unexpected: buddy removal failed, can't find " + c + " in local buddy list")
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]),
        b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnBlockBuddy = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = a[SFS2X.Requests.BuddyList.BlockBuddyRequest.KEY_BUDDY_NAME], d = this._sfs.buddyManager.getBuddyByName(c);
        null != d ? (d.blocked = a[SFS2X.Requests.BuddyList.BlockBuddyRequest.KEY_BUDDY_BLOCK_STATE], b.buddy = d, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_BLOCK, b)) : this._log.warn("Unexpected: buddy blocking/unblocking failed, can't find " + c + " in local buddy list")
    } else c =
        a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnGoOnline = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        var c = a[SFS2X.Requests.BuddyList.GoOnlineRequest.KEY_BUDDY_NAME], d = this._sfs.buddyManager.getBuddyByName(c), e = c == this._sfs.mySelf.name, f = a[SFS2X.Requests.BuddyList.GoOnlineRequest.KEY_ONLINE], g = f == SFS2X.Utils.BuddyOnlineState.ONLINE, h = !0;
        if (e)this._sfs.buddyManager.getMyOnlineState() != g && (this._log.warn("Unexpected: myOnlineState is not in synch with the server; resynching to: " +
            g), this._sfs.buddyManager._setMyOnlineState(g)); else if (null != d)d.id = a[SFS2X.Requests.BuddyList.GoOnlineRequest.KEY_BUDDY_ID], d._setVariable(new SFS2X.Entities.Variables.SFSBuddyVariable(SFS2X.Entities.Variables.ReservedBuddyVariables.BV_ONLINE, g)), f == SFS2X.Utils.BuddyOnlineState.LEFT_THE_SERVER && d._clearVolatileVariables(), h = this._sfs.buddyManager.getMyOnlineState(); else {
            this._log.warn("Unexpected:  buddy '" + c + "' not found in local Buddy List when trying to set his online state");
            return
        }
        h && (b.buddy =
            d, b.isItMe = e, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_ONLINE_STATE_CHANGE, b))
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_ERROR, b)
};
SFS2X.Controllers.SystemController.prototype._fnSetBuddyVariables = function (a) {
    var b = {};
    if (null == a[SFS2X.Controllers.KEY_ERROR_CODE]) {
        for (var c = a[SFS2X.Requests.BuddyList.SetBuddyVariablesRequest.KEY_BUDDY_NAME], a = a[SFS2X.Requests.BuddyList.SetBuddyVariablesRequest.KEY_BUDDY_VARS], d = this._sfs.buddyManager.getBuddyByName(c), e = c == this._sfs.mySelf.name, f = [], g = [], h = !0, i = 0; i < a.length; i++) {
            var j = SFS2X.Entities.Variables.SFSBuddyVariable.fromArray(a[i]);
            g.push(j);
            f.push(j.name)
        }
        if (e)this._sfs.buddyManager._setMyVariables(g);
        else if (null != d)d._setVariables(g), h = sfs.buddyManager.getMyOnlineState(); else {
            this._log.warn("Unexpected:  buddy '" + c + "' not found in local Buddy List when trying to set his Buddy Variables");
            return
        }
        h && (b.buddy = d, b.isItMe = e, b.changedVars = f, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_VARIABLES_UPDATE, b))
    } else c = a[SFS2X.Controllers.KEY_ERROR_CODE], a = SFS2X.ErrorCodes.getErrorMessage(c, a[SFS2X.Controllers.KEY_ERROR_PARAMS]), b.errorMessage = a, b.errorCode = c, this._sfs._dispatchEvent(SFS2X.SFSBuddyEvent.BUDDY_ERROR,
        b)
};
SFS2X.Controllers.SystemController.prototype._populateRoomList = function (a) {
    for (var b = this._sfs.roomManager, c = 0; c < a.length; c++) {
        var d = SFS2X.Entities.SFSRoom.fromArray(a[c]);
        b._replaceRoom(d)
    }
};
SFS2X.Controllers.SystemController.prototype._getOrCreateUser = function (a, b, c) {
    null == b && (b = !1);
    var d = this._sfs.userManager.getUserById(a[0]);
    if (null == d)d = SFS2X.Entities.SFSUser.fromArray(a, c), d._setUserManager(this._sfs.userManager); else if (null != c) {
        d._setPlayerId(a[3], c);
        a = a[4];
        for (c = 0; c < a.length; c++)d._setVariable(SFS2X.Entities.Variables.SFSUserVariable.fromArray(a[c]))
    }
    b && this._sfs.userManager._addUser(d);
    return d
};
SFS2X.Controllers.ExtensionController = function (a) {
    this.KEY_CMD = "c";
    this.KEY_PARAMS = "p";
    this.KEY_ROOM = "r";
    this._sfs = a;
    this._id = 1;
    this._log = SFS2X.Logger
};
SFS2X.Controllers.ExtensionController.prototype.getId = function () {
    return this._id
};
SFS2X.Controllers.ExtensionController.prototype.handleMessage = function (a) {
    this._sfs.debug && this._log.info("IN < ExtensionResponse");
    var b = {};
    b.cmd = a[this.KEY_CMD];
    b.params = a[this.KEY_PARAMS];
    null != a[this.KEY_ROOM] && (b.sourceRoom = a[this.KEY_ROOM]);
    this._sfs._dispatchEvent(SFS2X.SFSEvent.EXTENSION_RESPONSE, b)
};
SFS2X.DebugHelper = {};
SFS2X.DebugHelper.getDump = function (a) {
    return void 0 == a ? "<Null>" : a instanceof Object ? this._dumpObject(a) : "<Not An Object>"
};
SFS2X.DebugHelper._dumpObject = function (a) {
    function b(a, c, f) {
        var g = null;
        SFS2X.DebugHelper._getTabs(f);
        for (var h in a) {
            var i = a[h];
            if (null == i)g = "Null"; else {
                var j = i.constructor, k = void 0;
                j === Array || j === Object ? (g = null, k = j === Array ? "[Array]" : "[Object]", b(i, c, f + 1)) : g = i.constructor === Number ? "Num" : i.constructor === Boolean ? "Bool" : i.constructor === String ? "Str" : "Unsupported"
            }
            c.push(SFS2X.DebugHelper._getTabs(f) + h + ": " + (void 0 == k ? i : k) + (void 0 == g ? "" : " (" + g + ")"))
        }
    }

    var c = [];
    b(a, c, 0);
    return SFS2X.DebugHelper._prettyPrint(c)
};
SFS2X.DebugHelper._getTabs = function (a) {
    if (0 >= a)return"";
    if (1 == a)return"\t";
    for (var b = "", c = 0; c < a; c++)b += "\t";
    return b
};
SFS2X.DebugHelper._prettyPrint = function (a) {
    for (var b = "", c = a.length - 1; -1 < c; c--)b += a[c] + "\n";
    return b
};
SFS2X.Entities = {};
SFS2X.Entities.Variables = {};
SFS2X.Entities.Match = {};
SFS2X.Entities.Invitation = {};
SFS2X.Entities.SFSRoom = function (a, b, c) {
    this.id = a;
    this.name = b;
    this.groupId = null != c ? c : "default";
    this._isManaged = !0;
    this.isPasswordProtected = this.isJoined = this.isHidden = this.isGame = !1;
    this._specCount = this._userCount = this.maxSpectators = this.maxUsers = 0;
    this.variables = {};
    this.properties = {};
    this._userManager = new SFS2X.Managers.UserManager;
    this._roomManager = null
};
SFS2X.Entities.SFSRoom.fromArray = function (a) {
    var b = new SFS2X.Entities.SFSRoom(a[0], a[1], a[2]);
    b.isGame = a[3];
    b.isHidden = a[4];
    b.isPasswordProtected = a[5];
    b._userCount = a[6];
    b.maxUsers = a[7];
    var c = a[8];
    if (null != c)for (var d = 0; d < c.length; d++) {
        var e = SFS2X.Entities.Variables.SFSRoomVariable.fromArray(c[d]);
        b._setVariable(e)
    }
    b.isGame && (b._specCount = a[9], b.maxSpectators = a[10]);
    return b
};
SFS2X.Entities.SFSRoom.prototype.toString = function () {
    return"[Room: " + this.name + ", Id: " + this.id + ", Group id: " + this.groupId + "]"
};
SFS2X.Entities.SFSRoom.prototype.getUserCount = function () {
    return this._isJoined ? this.isGame ? this.getPlayerList().length : this._userManager.getUserCount() : this._userCount
};
SFS2X.Entities.SFSRoom.prototype.getSpectatorCount = function () {
    return!this.isGame ? 0 : this._isJoined ? this.getSpectatorList().length : this._specCount
};
SFS2X.Entities.SFSRoom.prototype.getCapacity = function () {
    return this.maxUsers + this.maxSpectators
};
SFS2X.Entities.SFSRoom.prototype.getUserByName = function (a) {
    return this._userManager.getUserByName(a)
};
SFS2X.Entities.SFSRoom.prototype.getUserById = function (a) {
    return this._userManager.getUserById(a)
};
SFS2X.Entities.SFSRoom.prototype.containsUser = function (a) {
    return this._userManager.containsUser(a)
};
SFS2X.Entities.SFSRoom.prototype.getUserList = function () {
    return this._userManager.getUserList()
};
SFS2X.Entities.SFSRoom.prototype.getPlayerList = function () {
    for (var a = [], b = this._userManager.getUserList(), c = 0; c < b.length; c++) {
        var d = b[c];
        d.isPlayerInRoom(this) && a.push(d)
    }
    return a
};
SFS2X.Entities.SFSRoom.prototype.getSpectatorList = function () {
    for (var a = [], b = this._userManager.getUserList(), c = 0; c < b.length; c++) {
        var d = b[c];
        d.isSpectatorInRoom(this) && a.push(d)
    }
    return a
};
SFS2X.Entities.SFSRoom.prototype.getVariable = function (a) {
    return this.variables[a]
};
SFS2X.Entities.SFSRoom.prototype.containsVariable = function (a) {
    return null != this.variables[a]
};
SFS2X.Entities.SFSRoom.prototype.getVariables = function () {
    return SFS2X.Utils.ArrayUtil.objToArray(this.variables)
};
SFS2X.Entities.SFSRoom.prototype.getRoomManager = function () {
    return this._roomManager
};
SFS2X.Entities.SFSRoom.prototype._addUser = function (a) {
    this._userManager._addUser(a)
};
SFS2X.Entities.SFSRoom.prototype._removeUser = function (a) {
    this._userManager._removeUser(a)
};
SFS2X.Entities.SFSRoom.prototype._setVariables = function (a) {
    for (var b in a)this._setVariable(a[b])
};
SFS2X.Entities.SFSRoom.prototype._setVariable = function (a) {
    a.isNull() ? delete this.variables[a.name] : this.variables[a.name] = a
};
SFS2X.Entities.SFSRoom.prototype._setRoomManager = function (a) {
    if (null != this._roomManager)throw new SFS2X.Exceptions.SFSError("Room Manager already assigned to Room " + this.toString());
    this._roomManager = a
};
SFS2X.Entities.SFSRoom.prototype._merge = function (a) {
    for (var b in a.variables)this.variables[b] = a.variables[b];
    this._userManager._clearAll();
    a = a.getUserList();
    for (b = 0; b < a.length; b++)this._userManager._addUser(a[b])
};
SFS2X.Entities.SFSUser = function (a, b, c) {
    this.id = a;
    this.name = b;
    this.isItMe = null != c ? c : !1;
    this.privilegeId = 0;
    this.variables = {};
    this.properties = {};
    this._playerIdByRoomId = {};
    this._userManager = null
};
SFS2X.Entities.SFSUser.fromArray = function (a, b) {
    var c = new SFS2X.Entities.SFSUser(a[0], a[1]);
    c.privilegeId = a[2];
    null != b && c._setPlayerId(a[3], b);
    var d = a[4];
    if (null != d)for (var e = 0; e < d.length; e++) {
        var f = SFS2X.Entities.Variables.SFSUserVariable.fromArray(d[e]);
        c._setVariable(f)
    }
    return c
};
SFS2X.Entities.SFSUser.prototype.toString = function () {
    return"[User: " + this.name + ", Id: " + this.id + ", Is me: " + this.isItMe + "]"
};
SFS2X.Entities.SFSUser.prototype.isJoinedInRoom = function (a) {
    return a.containsUser(this)
};
SFS2X.Entities.SFSUser.prototype.isGuest = function () {
    return this.privilegeId == SFS2X.Entities.UserPrivileges.GUEST
};
SFS2X.Entities.SFSUser.prototype.isStandardUser = function () {
    return this.privilegeId == SFS2X.Entities.UserPrivileges.STANDARD
};
SFS2X.Entities.SFSUser.prototype.isModerator = function () {
    return this.privilegeId == SFS2X.Entities.UserPrivileges.MODERATOR
};
SFS2X.Entities.SFSUser.prototype.isAdmin = function () {
    return this.privilegeId == SFS2X.Entities.UserPrivileges.ADMINISTRATOR
};
SFS2X.Entities.SFSUser.prototype.isPlayer = function () {
    return this.isPlayerInRoom(this._userManager._sfs.lastJoinedRoom)
};
SFS2X.Entities.SFSUser.prototype.isSpectator = function () {
    return this.isSpectatorInRoom(this._userManager._sfs.lastJoinedRoom)
};
SFS2X.Entities.SFSUser.prototype.getPlayerId = function (a) {
    var b = 0;
    null != this._playerIdByRoomId[a.id] && (b = this._playerIdByRoomId[a.id]);
    return b
};
SFS2X.Entities.SFSUser.prototype.isPlayerInRoom = function (a) {
    return null != a && a.isGame ? 0 < this._playerIdByRoomId[a.id] : !1
};
SFS2X.Entities.SFSUser.prototype.isSpectatorInRoom = function (a) {
    return null != a && a.isGame ? 0 > this._playerIdByRoomId[a.id] : !1
};
SFS2X.Entities.SFSUser.prototype.getVariable = function (a) {
    return this.variables[a]
};
SFS2X.Entities.SFSUser.prototype.containsVariable = function (a) {
    return null != this.variables[a]
};
SFS2X.Entities.SFSUser.prototype.getVariables = function () {
    return SFS2X.Utils.ArrayUtil.objToArray(this.variables)
};
SFS2X.Entities.SFSUser.prototype.getUserManager = function () {
    return this._userManager
};
SFS2X.Entities.SFSUser.prototype._setPlayerId = function (a, b) {
    this._playerIdByRoomId[b.id] = a
};
SFS2X.Entities.SFSUser.prototype._removePlayerId = function (a) {
    delete this._playerIdByRoomId[a.id]
};
SFS2X.Entities.SFSUser.prototype._setVariables = function (a) {
    for (var b in a)this._setVariable(a[b])
};
SFS2X.Entities.SFSUser.prototype._setVariable = function (a) {
    a.isNull() ? delete this.variables[a.name] : this.variables[a.name] = a
};
SFS2X.Entities.SFSUser.prototype._setUserManager = function (a) {
    if (null != this._userManager)throw new SFS2X.Exceptions.SFSError("User Manager already assigned to user " + this.toString());
    this._userManager = a
};
SFS2X.Entities.SFSBuddy = function (a, b, c, d) {
    this.id = a;
    this.name = b;
    this.blocked = null != c ? c : !1;
    this.temp = null != d ? d : !1;
    this.variables = {}
};
SFS2X.Entities.SFSBuddy.fromArray = function (a) {
    for (var b = new SFS2X.Entities.SFSBuddy(a[0], a[1], a[2], 4 < a.length ? a[4] : !1), a = a[3], c = 0; c < a.length; c++) {
        var d = SFS2X.Entities.Variables.SFSBuddyVariable.fromArray(a[c]);
        b._setVariable(d)
    }
    return b
};
SFS2X.Entities.SFSBuddy.prototype.toString = function () {
    return"[Buddy: " + this.name + ", Id: " + this.id + "]"
};
SFS2X.Entities.SFSBuddy.prototype.isBlocked = function () {
    return this.blocked
};
SFS2X.Entities.SFSBuddy.prototype.isTemp = function () {
    return this.temp
};
SFS2X.Entities.SFSBuddy.prototype.isOnline = function () {
    var a = !0, b = SFS2X.Entities.Variables.ReservedBuddyVariables.BV_ONLINE;
    this.containsVariable(b) && (a = this.getVariable(b).value);
    return a && -1 < this.id
};
SFS2X.Entities.SFSBuddy.prototype.getState = function () {
    var a = SFS2X.Entities.Variables.ReservedBuddyVariables.BV_STATE;
    return this.containsVariable(a) ? this.getVariable(a).value : null
};
SFS2X.Entities.SFSBuddy.prototype.getNickName = function () {
    var a = SFS2X.Entities.Variables.ReservedBuddyVariables.BV_NICKNAME;
    return this.containsVariable(a) ? this.getVariable(a).value : null
};
SFS2X.Entities.SFSBuddy.prototype.getVariable = function (a) {
    return this.variables[a]
};
SFS2X.Entities.SFSBuddy.prototype.containsVariable = function (a) {
    return null != this.variables[a]
};
SFS2X.Entities.SFSBuddy.prototype.getVariables = function () {
    return SFS2X.Utils.ArrayUtil.objToArray(this.variables)
};
SFS2X.Entities.SFSBuddy.prototype.getOfflineVariables = function () {
    var a = [], b;
    for (b in this.variables) {
        var c = this.variables[b];
        c.name.charAt(0) == SFS2X.Entities.Variables.SFSBuddyVariable.OFFLINE_PREFIX && a.push(c)
    }
    return a
};
SFS2X.Entities.SFSBuddy.prototype.getOnlineVariables = function () {
    var a = [], b;
    for (b in this.variables) {
        var c = this.variables[b];
        c.name.charAt(0) != SFS2X.Entities.Variables.SFSBuddyVariable.OFFLINE_PREFIX && a.push(c)
    }
    return a
};
SFS2X.Entities.SFSBuddy.prototype._setVariables = function (a) {
    for (var b in a)this._setVariable(a[b])
};
SFS2X.Entities.SFSBuddy.prototype._setVariable = function (a) {
    a.isNull() ? this._removeVariable(a.name) : this.variables[a.name] = a
};
SFS2X.Entities.SFSBuddy.prototype._removeVariable = function (a) {
    delete this.variables[a]
};
SFS2X.Entities.SFSBuddy.prototype._clearVolatileVariables = function () {
    for (var a in this.variables) {
        var b = this.variables[a];
        b.name.charAt(0) != SFS2X.Entities.Variables.SFSBuddyVariable.OFFLINE_PREFIX && this._removeVariable(b.name)
    }
};
SFS2X.Entities.Variables.SFSUserVariable = Class.extend({init: function (a, b, c) {
    this.name = a;
    this.value = b;
    this._setType(c)
}, toString: function () {
    return"[UserVar: " + this.name + ", Type: " + this.type + ", Value: " + this.value + "]"
}, toArray: function () {
    return[this.name, SFS2X.Entities.Variables.VariableType.getTypeIdFromName(this.type), this.value]
}, isNull: function () {
    return SFS2X.Entities.Variables.VariableType.getTypeIdFromName(this.type) == SFS2X.Entities.Variables.VariableType.NULL
}, _setType: function (a) {
    null == a && (a = -1);
    -1 < a ? this.type = this.getTypeName(a) : null == this.value ? this.type = this.getTypeName(SFS2X.Entities.Variables.VariableType.NULL) : (a = typeof this.value, "boolean" == a ? this.type = this.getTypeName(SFS2X.Entities.Variables.VariableType.BOOL) : "number" == a ? this.type = this.value === +this.value && this.value === (this.value | 0) ? this.getTypeName(SFS2X.Entities.Variables.VariableType.INT) : this.getTypeName(SFS2X.Entities.Variables.VariableType.DOUBLE) : "string" == a ? this.type = this.getTypeName(SFS2X.Entities.Variables.VariableType.STRING) :
        "object" == a && (this.type = this.value instanceof Array ? this.getTypeName(SFS2X.Entities.Variables.VariableType.ARRAY) : this.getTypeName(SFS2X.Entities.Variables.VariableType.OBJECT)))
}, getTypeName: function (a) {
    return SFS2X.Entities.Variables.VariableType.getTypeName(a)
}});
SFS2X.Entities.Variables.SFSUserVariable.fromArray = function (a) {
    return new SFS2X.Entities.Variables.SFSUserVariable(a[0], a[2], a[1])
};
SFS2X.Entities.Variables.SFSRoomVariable = SFS2X.Entities.Variables.SFSUserVariable.extend({init: function (a, b, c) {
    this._super(a, b, c);
    this.isPersistent = this.isPrivate = !1
}, toString: function () {
    return"[RoomVar: " + this.name + ", Type: " + this.type + ", Value: " + this.value + ", Is private: " + this.isPrivate + "]"
}, toArray: function () {
    var a = this._super();
    a.push(this.isPrivate);
    a.push(this.isPersistent);
    return a
}});
SFS2X.Entities.Variables.SFSRoomVariable.fromArray = function (a) {
    var b = new SFS2X.Entities.Variables.SFSRoomVariable(a[0], a[2], a[1]);
    b.isPrivate = a[3];
    b.isPersistent = a[4];
    return b
};
SFS2X.Entities.Variables.SFSBuddyVariable = SFS2X.Entities.Variables.SFSUserVariable.extend({init: function (a, b, c) {
    this._super(a, b, c)
}, toString: function () {
    return"[BuddyVar: " + this.name + ", Type: " + this.type + ", Value: " + this.value + "]"
}, isOffline: function () {
    return this.name.charAt(0) == SFS2X.Entities.Variables.SFSBuddyVariable.OFFLINE_PREFIX
}});
SFS2X.Entities.Variables.SFSBuddyVariable.OFFLINE_PREFIX = "$";
SFS2X.Entities.Variables.SFSBuddyVariable.fromArray = function (a) {
    return new SFS2X.Entities.Variables.SFSBuddyVariable(a[0], a[2], a[1])
};
SFS2X.Entities.Variables.VariableType = {_typeStrings: "Null Bool Int Double String Object Array".split(" "), NULL: 0, BOOL: 1, INT: 2, DOUBLE: 3, STRING: 4, OBJECT: 5, ARRAY: 6};
SFS2X.Entities.Variables.VariableType.getTypeName = function (a) {
    return this._typeStrings[a]
};
SFS2X.Entities.Variables.VariableType.getTypeIdFromName = function (a) {
    return this._typeStrings.indexOf(a)
};
SFS2X.Entities.Variables.ReservedBuddyVariables = {};
SFS2X.Entities.Variables.ReservedBuddyVariables.BV_ONLINE = "$__BV_ONLINE__";
SFS2X.Entities.Variables.ReservedBuddyVariables.BV_STATE = "$__BV_STATE__";
SFS2X.Entities.Variables.ReservedBuddyVariables.BV_NICKNAME = "$__BV_NICKNAME__";
SFS2X.Entities.Variables.ReservedRoomVariables = {};
SFS2X.Entities.Variables.ReservedRoomVariables.RV_GAME_STARTED = "$GS";
SFS2X.Entities.UserPrivileges = {};
SFS2X.Entities.UserPrivileges.GUEST = 0;
SFS2X.Entities.UserPrivileges.STANDARD = 1;
SFS2X.Entities.UserPrivileges.MODERATOR = 2;
SFS2X.Entities.UserPrivileges.ADMINISTRATOR = 3;
SFS2X.Entities.Match.MatchExpression = function (a, b, c) {
    this.varName = a;
    this.condition = b;
    this.value = c;
    this._parent = this.next = this.logicOp = null
};
SFS2X.Entities.Match.MatchExpression.chainedMatchExpression = function (a, b, c, d, e) {
    a = new SFS2X.Entities.Match.MatchExpression(a, b, c);
    a.logicOp = d;
    a._parent = e;
    return a
};
SFS2X.Entities.Match.MatchExpression.prototype.and = function (a, b, c) {
    return this.next = SFS2X.Entities.Match.MatchExpression.chainedMatchExpression(a, b, c, SFS2X.Entities.Match.LogicOperator.AND, this)
};
SFS2X.Entities.Match.MatchExpression.prototype.or = function (a, b, c) {
    return this.next = SFS2X.Entities.Match.MatchExpression.chainedMatchExpression(a, b, c, SFS2X.Entities.Match.LogicOperator.OR, this)
};
SFS2X.Entities.Match.MatchExpression.prototype.hasNext = function () {
    return null != this.next
};
SFS2X.Entities.Match.MatchExpression.prototype.rewind = function () {
    for (var a = this; ;)if (null != a._parent)a = a._parent; else break;
    return a
};
SFS2X.Entities.Match.MatchExpression.prototype.toString = function () {
    for (var a = this.rewind(), b = a._asString(); a.hasNext();)a = a.next, b += a._asString();
    return b
};
SFS2X.Entities.Match.MatchExpression.prototype._asString = function () {
    var a = "";
    null != this.logicOp && (a += " " + this.logicOp.id + " ");
    a = a + "(" + (this.varName + " " + this.condition.symbol + " " + ("string" == typeof this.value ? "'" + this.value + "'" : this.value));
    return a + ")"
};
SFS2X.Entities.Match.MatchExpression.prototype._toArray = function () {
    var a = this.rewind(), b = [];
    for (b.push(a._expressionAsArray()); a.hasNext();)a = a.next, b.push(a._expressionAsArray());
    return b
};
SFS2X.Entities.Match.MatchExpression.prototype._expressionAsArray = function () {
    var a = [];
    null != this.logicOp ? a.push(this.logicOp.id) : a.push(null);
    a.push(this.varName);
    a.push(this.condition.type);
    a.push(this.condition.symbol);
    a.push(this.value);
    return a
};
SFS2X.Entities.Match.LogicOperator = function (a) {
    this.id = a
};
SFS2X.Entities.Match.LogicOperator.AND = new SFS2X.Entities.Match.LogicOperator("AND");
SFS2X.Entities.Match.LogicOperator.OR = new SFS2X.Entities.Match.LogicOperator("OR");
SFS2X.Entities.Match.BoolMatch = function (a) {
    this.type = 0;
    this.symbol = a
};
SFS2X.Entities.Match.BoolMatch.EQUALS = new SFS2X.Entities.Match.BoolMatch("==");
SFS2X.Entities.Match.BoolMatch.NOT_EQUALS = new SFS2X.Entities.Match.BoolMatch("!=");
SFS2X.Entities.Match.NumberMatch = function (a) {
    this.type = 1;
    this.symbol = a
};
SFS2X.Entities.Match.NumberMatch.EQUALS = new SFS2X.Entities.Match.NumberMatch("==");
SFS2X.Entities.Match.NumberMatch.NOT_EQUALS = new SFS2X.Entities.Match.NumberMatch("!=");
SFS2X.Entities.Match.NumberMatch.GREATER_THAN = new SFS2X.Entities.Match.NumberMatch(">");
SFS2X.Entities.Match.NumberMatch.GREATER_THAN_OR_EQUAL_TO = new SFS2X.Entities.Match.NumberMatch(">=");
SFS2X.Entities.Match.NumberMatch.LESS_THAN = new SFS2X.Entities.Match.NumberMatch("<");
SFS2X.Entities.Match.NumberMatch.LESS_THAN_OR_EQUAL_TO = new SFS2X.Entities.Match.NumberMatch("<=");
SFS2X.Entities.Match.StringMatch = function (a) {
    this.type = 2;
    this.symbol = a
};
SFS2X.Entities.Match.StringMatch.EQUALS = new SFS2X.Entities.Match.StringMatch("==");
SFS2X.Entities.Match.StringMatch.NOT_EQUALS = new SFS2X.Entities.Match.StringMatch("!=");
SFS2X.Entities.Match.StringMatch.CONTAINS = new SFS2X.Entities.Match.StringMatch("contains");
SFS2X.Entities.Match.StringMatch.STARTS_WITH = new SFS2X.Entities.Match.StringMatch("startsWith");
SFS2X.Entities.Match.StringMatch.ENDS_WITH = new SFS2X.Entities.Match.StringMatch("endsWith");
SFS2X.Entities.Match.RoomProperties = {};
SFS2X.Entities.Match.RoomProperties.NAME = "${N}";
SFS2X.Entities.Match.RoomProperties.GROUP_ID = "${G}";
SFS2X.Entities.Match.RoomProperties.MAX_USERS = "${MXU}";
SFS2X.Entities.Match.RoomProperties.MAX_SPECTATORS = "${MXS}";
SFS2X.Entities.Match.RoomProperties.USER_COUNT = "${UC}";
SFS2X.Entities.Match.RoomProperties.SPECTATOR_COUNT = "${SC}";
SFS2X.Entities.Match.RoomProperties.IS_GAME = "${ISG}";
SFS2X.Entities.Match.RoomProperties.IS_PRIVATE = "${ISP}";
SFS2X.Entities.Match.RoomProperties.HAS_FREE_PLAYER_SLOTS = "${HFP}";
SFS2X.Entities.Match.RoomProperties.IS_TYPE_SFSGAME = "${IST}";
SFS2X.Entities.Match.UserProperties = {};
SFS2X.Entities.Match.UserProperties.NAME = "${N}";
SFS2X.Entities.Match.UserProperties.IS_PLAYER = "${ISP}";
SFS2X.Entities.Match.UserProperties.IS_SPECTATOR = "${ISS}";
SFS2X.Entities.Match.UserProperties.IS_NPC = "${ISN}";
SFS2X.Entities.Match.UserProperties.PRIVILEGE_ID = "${PRID}";
SFS2X.Entities.Match.UserProperties.IS_IN_ANY_ROOM = "${IAR}";
SFS2X.Entities.Invitation.SFSInvitation = function (a, b, c, d) {
    this.id = -1;
    this.inviter = a;
    this.invitee = b;
    this.secondsForAnswer = null != c ? c : 15;
    this.params = d
};
SFS2X.Entities.Invitation.InvitationReply = {};
SFS2X.Entities.Invitation.InvitationReply.ACCEPT = 0;
SFS2X.Entities.Invitation.InvitationReply.REFUSE = 1;
SFS2X.ErrorCodes = {};
SFS2X.ErrorCodes._errorsByCode = ["Client API version is obsolete: {0}; required version: {1}", "Requested Zone {0} does not exist", "User name {0} is not recognized", "Wrong password for user {0}", "User {0} is banned", "Zone {0} is full", "User {0} is already logged in Zone {1}", "The server is full", "Zone {0} is currently inactive", "User name {0} contains bad words; filtered: {1}", "Guest users not allowed in Zone {0}", "IP address {0} is banned", "A Room with the same name already exists: {0}", "Requested Group is not available - Room: {0}; Group: {1}",
    "Bad Room name length -  Min: {0}; max: {1}; passed name length: {2}", "Room name contains bad words: {0}", "Zone is full; can't add Rooms anymore", "You have exceeded the number of Rooms that you can create per session: {0}", "Room creation failed, wrong parameter: {0}", "User {0} already joined in Room", "Room {0} is full", "Wrong password for Room {0}", "Requested Room does not exist", "Room {0} is locked", "Group {0} is already subscribed", "Group {0} does not exist", "Group {0} is not subscribed", "Group {0} does not exist",
    "{0}", "Room permission error; Room {0} cannot be renamed", "Room permission error; Room {0} cannot change password state", "Room permission error; Room {0} cannot change capacity", "Switch user error; no player slots available in Room {0}", "Switch user error; no spectator slots available in Room {0}", "Switch user error; Room {0} is not a Game Room", "Switch user error; you are not joined in Room {0}", "Buddy Manager initialization error, could not load buddy list: {0}", "Buddy Manager error, your buddy list is full; size is {0}",
    "Buddy Manager error, was not able to block buddy {0} because offline", "Buddy Manager error, you are attempting to set too many Buddy Variables; limit is {0}", "Game {0} access denied, user does not match access criteria", "QuickJoinGame action failed: no matching Rooms were found", "Your previous invitation reply was invalid or arrived too late"];
SFS2X.ErrorCodes.setErrorMessage = function (a, b) {
    this._errorsByCode[a] = b
};
SFS2X.ErrorCodes.getErrorMessage = function (a, b) {
    return this.stringFormat(this._errorsByCode[a], b)
};
SFS2X.ErrorCodes.stringFormat = function (a, b) {
    if (null == a)return"";
    if (null != b)for (var c = 0; c < b.length; c++)a = a.replace("{" + c + "}", b[c]);
    return a
};
SFS2X.EventDispatcher = function () {
    this.listenersByEvent = {}
};
SFS2X.EventDispatcher.prototype.addEventListener = function (a, b, c) {
    null == this.listenersByEvent[a] && (this.listenersByEvent[a] = []);
    this.listenersByEvent[a].push({listener: b, scope: c})
};
SFS2X.EventDispatcher.prototype.removeEventListener = function (a, b) {
    var c = this.listenersByEvent[a];
    if (null != listenersByEvent)for (var d = 0; d < c.length; d++)if (c[d].listener === b) {
        c.splice(d, 1);
        break
    }
};
SFS2X.EventDispatcher.prototype.dispatchEvent = function (a, b) {
    var c = this.listenersByEvent[a];
    if (c && 0 < c.length)for (var d = 0; d < c.length; d++)c[d].listener.call(c[d].scope, b)
};
SFS2X.EventDispatcher.prototype.getListeners = function (a) {
    return listeners[a]
};
SFS2X.SFSEvent = {HANDSHAKE: "handshake", CONNECTION: "connection", CONNECTION_LOST: "connectionLost", CONNECTION_RETRY: "connectionRetry", CONNECTION_RESUME: "connectionResume", LOGIN: "login", LOGIN_ERROR: "loginError", LOGOUT: "logout", ROOM_ADD: "roomAdd", ROOM_CREATION_ERROR: "roomCreationError", ROOM_REMOVE: "roomRemove", ROOM_JOIN: "roomJoin", ROOM_JOIN_ERROR: "roomJoinError", USER_ENTER_ROOM: "userEnterRoom", USER_EXIT_ROOM: "userExitRoom", USER_COUNT_CHANGE: "userCountChange", PLAYER_TO_SPECTATOR: "playerToSpectator", PLAYER_TO_SPECTATOR_ERROR: "playerToSpectatorError",
    SPECTATOR_TO_PLAYER: "spectatorToPlayer", SPECTATOR_TO_PLAYER_ERROR: "spectatorToPlayerError", ROOM_NAME_CHANGE: "roomNameChange", ROOM_NAME_CHANGE_ERROR: "roomNameChangeError", ROOM_PASSWORD_STATE_CHANGE: "roomPasswordStateChange", ROOM_PASSWORD_STATE_CHANGE_ERROR: "roomPasswordStateChangeError", ROOM_CAPACITY_CHANGE: "roomCapacityChange", ROOM_CAPACITY_CHANGE_ERROR: "roomCapacityChangeError", PUBLIC_MESSAGE: "publicMessage", PRIVATE_MESSAGE: "privateMessage", OBJECT_MESSAGE: "objectMessage", MODERATOR_MESSAGE: "moderatorMessage",
    ADMIN_MESSAGE: "adminMessage", EXTENSION_RESPONSE: "extensionResponse", ROOM_VARIABLES_UPDATE: "roomVariablesUpdate", USER_VARIABLES_UPDATE: "userVariablesUpdate", ROOM_GROUP_SUBSCRIBE: "roomGroupSubscribe", ROOM_GROUP_SUBSCRIBE_ERROR: "roomGroupSubscribeError", ROOM_GROUP_UNSUBSCRIBE: "roomGroupUnsubscribe", ROOM_GROUP_UNSUBSCRIBE_ERROR: "roomGroupUnsubscribeError", ROOM_FIND_RESULT: "roomFindResult", USER_FIND_RESULT: "userFindResult", INVITATION: "invitation", INVITATION_REPLY: "invitationReply", INVITATION_REPLY_ERROR: "invitationReplyError",
    PING_PONG: "pingPong", SOCKET_ERROR: "socketError"};
SFS2X.SFSBuddyEvent = {BUDDY_LIST_INIT: "buddyListInit", BUDDY_ADD: "buddyAdd", BUDDY_REMOVE: "buddyRemove", BUDDY_BLOCK: "buddyBlock", BUDDY_ERROR: "buddyError", BUDDY_ONLINE_STATE_CHANGE: "buddyOnlineStateChange", BUDDY_VARIABLES_UPDATE: "buddyVariablesUpdate", BUDDY_MESSAGE: "buddyMessage"};
SFS2X.Exceptions = {};
SFS2X.Exceptions.SFSError = Class.extend({init: function (a) {
    this._messsage = a
}, getMessage: function () {
    return this._messsage
}});
SFS2X.Exceptions.SFSValidationError = SFS2X.Exceptions.SFSError.extend({init: function (a, b) {
    this._super(a);
    this._errrors = b
}, getErrors: function () {
    return this._errrors
}});
SFS2X.LogLevel = {DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3};
SFS2X._Logger = function () {
    this.isAvailable = void 0 != console;
    this.level = SFS2X.LogLevel.INFO
};
SFS2X.Logger = new SFS2X._Logger;
SFS2X._Logger.prototype.setLevel = function (a) {
    a < SFS2X.LogLevel.DEBUG || a > SFS2X.LogLevel.ERROR || (this.level = a)
};
SFS2X._Logger.prototype.debug = function (a) {
    this.isAvailable && this.level <= SFS2X.LogLevel.DEBUG && console.log("[DEBUG] " + a)
};
SFS2X._Logger.prototype.info = function (a) {
    this.isAvailable && this.level <= SFS2X.LogLevel.INFO && console.log("[INFO] " + a)
};
SFS2X._Logger.prototype.warn = function (a) {
    this.isAvailable && this.level <= SFS2X.LogLevel.WARN && console.log("[WARN] " + a)
};
SFS2X._Logger.prototype.error = function (a) {
    this.isAvailable && console.log("[ERROR] " + a)
};
SFS2X.Managers = {};
SFS2X.Managers.UserManager = Class.extend({init: function (a) {
    this._sfs = a;
    this._usersById = new SFS2X.Utils.HashTable;
    this._usersByName = new SFS2X.Utils.HashTable
}, containsUserName: function (a) {
    return this._usersByName.hasItem(a)
}, containsUserId: function (a) {
    return this._usersById.hasItem(a)
}, containsUser: function (a) {
    return this._usersById.hasItem(a.id)
}, getUserById: function (a) {
    return this._usersById.getItem(a)
}, getUserByName: function (a) {
    return this._usersByName.getItem(a)
}, getUserCount: function () {
    return this._usersById.length
}, getUserList: function () {
    return this._usersById.values()
},
    _addUser: function (a) {
        this._usersById.hasItem(a.id) && SFS2X.Logger.warn("Unexpected, duplicate user in UserManager: " + a.toString());
        this.__addUser(a)
    }, __addUser: function (a) {
        this._usersByName.setItem(a.name, a);
        this._usersById.setItem(a.id, a)
    }, _removeUser: function (a) {
        this._usersById.removeItem(a.id);
        this._usersByName.removeItem(a.name)
    }, _removeUserById: function () {
        this._usersById.removeItem(user.id);
        this._usersByName.removeItem(user.name)
    }, _clearAll: function () {
        this._usersById.clear();
        this._usersByName.clear()
    }});
SFS2X.Managers.GlobalUserManager = SFS2X.Managers.UserManager.extend({init: function (a) {
    this._super(a);
    this._roomRefCount = []
}, _addUser: function (a) {
    null == this._roomRefCount[a] ? this._roomRefCount[a] = 1 : this._roomRefCount[a]++;
    this.__addUser(a)
}, _removeUser: function (a) {
    null != this._roomRefCount ? 1 > this._roomRefCount[a] ? SFS2X.Logger.warn("GlobalUserManager RefCount is already at zero. User: " + a) : (this._roomRefCount[a]--, 0 == this._roomRefCount[a] && (this._removeUser(a), delete this._roomRefCount[a])) : SFS2X.Logger.warn("Can't remove User from GlobalUserManager. RefCount missing. User: " +
        a)
}, dumpRefCount: function () {
}});
SFS2X.Managers.RoomManager = function (a) {
    this._sfs = a;
    this._ownerZone = null;
    this._groups = [];
    this._roomsById = new SFS2X.Utils.HashTable;
    this._roomsByName = new SFS2X.Utils.HashTable
};
SFS2X.Managers.RoomManager.prototype.getRoomGroups = function () {
    return this._groups
};
SFS2X.Managers.RoomManager.prototype.containsGroup = function (a) {
    return-1 < this._groups.indexOf(a)
};
SFS2X.Managers.RoomManager.prototype.containsRoom = function (a) {
    return"number" == typeof a ? this._roomsById.hasItem(a) : this._roomsByName.hasItem(a)
};
SFS2X.Managers.RoomManager.prototype.containsRoomInGroup = function (a, b) {
    var c = this.getRoomListFromGroup(b), d = !1, e = "number" == typeof a, f;
    for (f in c) {
        var g = c[f];
        if (e) {
            if (g.id == a) {
                d = !0;
                break
            }
        } else if (g.name == a) {
            d = !0;
            break
        }
    }
    return d
};
SFS2X.Managers.RoomManager.prototype.getRoomById = function (a) {
    return this._roomsById.getItem(a)
};
SFS2X.Managers.RoomManager.prototype.getRoomByName = function (a) {
    return this._roomsByName.getItem(a)
};
SFS2X.Managers.RoomManager.prototype.getRoomList = function () {
    return this._roomsById.values()
};
SFS2X.Managers.RoomManager.prototype.getRoomCount = function () {
    return this._roomsById.length
};
SFS2X.Managers.RoomManager.prototype.getRoomListFromGroup = function (a) {
    var b = [], c;
    for (c in this._roomsById.items)if (this._roomsById.hasItem(c)) {
        var d = this._roomsById.items[c];
        d.groupId == a && b.push(d)
    }
    return b
};
SFS2X.Managers.RoomManager.prototype.getJoinedRooms = function () {
    var a = [], b;
    for (b in this._roomsById.items)if (this._roomsById.hasItem(b)) {
        var c = this._roomsById.items[b];
        c.isJoined && a.push(c)
    }
    return a
};
SFS2X.Managers.RoomManager.prototype.getUserRooms = function (a) {
    var b = [], c;
    for (c in this._roomsById.items)if (this._roomsById.hasItem(c)) {
        var d = this._roomsById.items[c];
        d.containsUser(a) && b.push(d)
    }
    return b
};
SFS2X.Managers.RoomManager.prototype._addRoom = function (a, b) {
    null == b && (b = !0);
    this._roomsById.setItem(a.id, a);
    this._roomsByName.setItem(a.name, a);
    b ? this.containsGroup(a.groupId) || this._addGroup(a.groupId) : a._isManaged = !1
};
SFS2X.Managers.RoomManager.prototype._replaceRoom = function (a, b) {
    null == b && (b = !0);
    var c = this.getRoomById(a.id);
    if (null != c)return c._merge(a), c;
    this._addRoom(a, b);
    return a
};
SFS2X.Managers.RoomManager.prototype._removeRoom = function (a) {
    this._roomsById.removeItem(a.id);
    this._roomsByName.removeItem(a.name)
};
SFS2X.Managers.RoomManager.prototype._removeRoomById = function (a) {
    a = this.getRoomById(a);
    null != a && this._removeRoom(a)
};
SFS2X.Managers.RoomManager.prototype._removeRoomByName = function (a) {
    a = this.getRoomByName(a);
    null != a && this._removeRoom(a)
};
SFS2X.Managers.RoomManager.prototype._changeRoomName = function (a, b) {
    var c = a.name;
    a.name = b;
    this._roomsByName.setItem(b, a);
    this._roomsByName.removeItem(c)
};
SFS2X.Managers.RoomManager.prototype._changeRoomPasswordState = function (a, b) {
    a.isPasswordProtected = b
};
SFS2X.Managers.RoomManager.prototype._changeRoomCapacity = function (a, b, c) {
    a.maxUsers = b;
    a.maxSpectators = c
};
SFS2X.Managers.RoomManager.prototype._addGroup = function (a) {
    this._groups.push(a)
};
SFS2X.Managers.RoomManager.prototype._removeGroup = function (a) {
    SFS2X.Utils.ArrayUtil.removeItem(this._groups, a);
    var a = this.getRoomListFromGroup(a), b;
    for (b in a) {
        var c = a[b];
        c.isJoined ? c._isManaged = !1 : this._removeRoom(c)
    }
};
SFS2X.Managers.RoomManager.prototype._removeUser = function (a) {
    for (var b in this._roomsById.items)if (this._roomsById.hasItem(b)) {
        var c = this._roomsById.items[b];
        c.containsUser(a) && c._removeUser(a)
    }
};
SFS2X.Managers.BuddyManager = function (a) {
    this._sfs = a;
    this._buddiesByName = [];
    this._myVariables = [];
    this._inited = !1;
    this._buddyStates = []
};
SFS2X.Managers.BuddyManager.prototype.isInited = function () {
    return this._inited
};
SFS2X.Managers.BuddyManager.prototype.containsBuddy = function (a) {
    return null != this.getBuddyByName(a)
};
SFS2X.Managers.BuddyManager.prototype.getBuddyById = function (a) {
    if (-1 < a)for (var b in this._buddiesByName) {
        var c = this._buddiesByName[b];
        if (c.id == a)return c
    }
    return null
};
SFS2X.Managers.BuddyManager.prototype.getBuddyByName = function (a) {
    return this._buddiesByName[a]
};
SFS2X.Managers.BuddyManager.prototype.getBuddyByNickName = function (a) {
    for (var b in this._buddiesByName) {
        var c = this._buddiesByName[b];
        if (c.nickName == a)return c
    }
    return null
};
SFS2X.Managers.BuddyManager.prototype.getOfflineBuddies = function () {
    var a = [], b;
    for (b in this._buddiesByName) {
        var c = this._buddiesByName[b];
        c.isOnline() || a.push(c)
    }
    return a
};
SFS2X.Managers.BuddyManager.prototype.getOnlineBuddies = function () {
    var a = [], b;
    for (b in this._buddiesByName) {
        var c = this._buddiesByName[b];
        c.isOnline() && a.push(c)
    }
    return a
};
SFS2X.Managers.BuddyManager.prototype.getBuddyList = function () {
    return SFS2X.Utils.ArrayUtil.objToArray(this._buddiesByName)
};
SFS2X.Managers.BuddyManager.prototype.getMyVariable = function (a) {
    return this._myVariables[a]
};
SFS2X.Managers.BuddyManager.prototype.getMyVariables = function () {
    return SFS2X.Utils.ArrayUtil.objToArray(this._myVariables)
};
SFS2X.Managers.BuddyManager.prototype.getMyOnlineState = function () {
    if (!this._inited)return!1;
    var a = !0, b = this.getMyVariable(SFS2X.Entities.Variables.ReservedBuddyVariables.BV_ONLINE);
    null != b && (a = b.value);
    return a
};
SFS2X.Managers.BuddyManager.prototype.getMyNickName = function () {
    var a = this.getMyVariable(SFS2X.Entities.Variables.ReservedBuddyVariables.BV_NICKNAME);
    return null != a ? a.value : null
};
SFS2X.Managers.BuddyManager.prototype.getMyState = function () {
    var a = this.getMyVariable(SFS2X.Entities.Variables.ReservedBuddyVariables.BV_STATE);
    return null != a ? a.value : null
};
SFS2X.Managers.BuddyManager.prototype.getBuddyStates = function () {
    return this._buddyStates
};
SFS2X.Managers.BuddyManager.prototype._setInited = function () {
    this._inited = !0
};
SFS2X.Managers.BuddyManager.prototype._addBuddy = function (a) {
    this._buddiesByName[a.name] = a
};
SFS2X.Managers.BuddyManager.prototype._clearAll = function () {
    this._buddiesByName = []
};
SFS2X.Managers.BuddyManager.prototype._removeBuddyById = function (a) {
    a = this.getBuddyById(a);
    null != a && delete this._buddiesByName[a.name];
    return a
};
SFS2X.Managers.BuddyManager.prototype._removeBuddyByName = function (a) {
    var b = this.getBuddyByName(a);
    null != b && delete this._buddiesByName[a];
    return b
};
SFS2X.Managers.BuddyManager.prototype._setMyVariables = function (a) {
    for (var b in a)this._setMyVariable(a[b])
};
SFS2X.Managers.BuddyManager.prototype._setMyVariable = function (a) {
    a.isNull() ? delete this._myVariables[a.name] : this._myVariables[a.name] = a
};
SFS2X.Managers.BuddyManager.prototype._setMyOnlineState = function (a) {
    a = new SFS2X.Entities.Variables.SFSBuddyVariable(SFS2X.Entities.Variables.ReservedBuddyVariables.BV_ONLINE, a);
    this._setMyVariable(a)
};
SFS2X.Managers.BuddyManager.prototype._setMyNickName = function (a) {
    a = new SFS2X.Entities.Variables.SFSBuddyVariable(SFS2X.Entities.Variables.ReservedBuddyVariables.BV_NICKNAME, a);
    this._setMyVariable(a)
};
SFS2X.Managers.BuddyManager.prototype._setMyState = function (a) {
    a = new SFS2X.Entities.Variables.SFSBuddyVariable(SFS2X.Entities.Variables.ReservedBuddyVariables.BV_STATE, a);
    this._setMyVariable(a)
};
SFS2X.Managers.BuddyManager.prototype._setBuddyStates = function (a) {
    this._buddyStates = a
};
SFS2X.Requests = {};
SFS2X.Requests.System = {};
SFS2X.Requests.BuddyList = {};
SFS2X.Requests.Game = {};
SFS2X.Requests._BaseRequest = Class.extend({init: function (a) {
    this._reqObj = {};
    this._id = a;
    this._targetController = 0;
    this._log = SFS2X.Logger
}, getMessage: function () {
    return{a: this._id, c: this._targetController, p: this._reqObj}
}, validate: function () {
    this._log.error("BaseRequest.validate = no child-class implementation found!")
}, execute: function () {
    this._log.error("BaseRequest.execute = no child-class implementation found!")
}});
SFS2X.Requests.System.HandshakeRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b) {
    this._super(SFS2X.Requests.Handshake);
    this._apiVersion = a;
    this._reconnectionToken = b
}, validate: function () {
}, execute: function () {
    this._reqObj[this.constructor.KEY_API] = this._apiVersion;
    this._reqObj[this.constructor.KEY_CLIENT_TYPE] = navigator.userAgent;
    null != this._reconnectionToken && (this.reqObj[this.constructor.KEY_RECONNECTION_TOKEN] = this._reconnectionToken)
}});
SFS2X.Requests.System.HandshakeRequest.KEY_SESSION_TOKEN = "tk";
SFS2X.Requests.System.HandshakeRequest.KEY_API = "api";
SFS2X.Requests.System.HandshakeRequest.KEY_COMPRESSION_THRESHOLD = "ct";
SFS2X.Requests.System.HandshakeRequest.KEY_RECONNECTION_TOKEN = "rt";
SFS2X.Requests.System.HandshakeRequest.KEY_CLIENT_TYPE = "cl";
SFS2X.Requests.System.HandshakeRequest.KEY_MAX_MESSAGE_SIZE = "ms";
SFS2X.Requests.System.LoginRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c, d) {
    this._super(SFS2X.Requests.Login);
    this._userName = a;
    this._password = b;
    this._params = c;
    this._zoneName = d
}, validate: function (a) {
    if (null != a.mySelf)throw new SFS2X.Exceptions.SFSValidationError("LoginRequest error", ["You are already logged in; logout before attempting a new login"]);
    a = null != a.config && null != a.config.zone ? a.config.zone : null;
    null != this._zoneName && (a = this._zoneName);
    if (null == a || 0 == a.length)throw new SFS2X.Exceptions.SFSValidationError("LoginRequest Error",
        ["Missing Zone name"]);
    this._zoneName = a;
    null == this._userName && (this._userName = "");
    null == this._password && (this._password = "")
}, execute: function (a) {
    this._reqObj[this.constructor.KEY_ZONE_NAME] = this._zoneName;
    this._reqObj[this.constructor.KEY_USER_NAME] = this._userName;
    this._reqObj[this.constructor.KEY_PASSWORD] = 0 < this._password.length ? hex_md5(a.sessionToken + this._password) : "";
    null != this._params && (this._reqObj[this.constructor.KEY_PARAMS] = this._params)
}});
SFS2X.Requests.System.LoginRequest.KEY_ZONE_NAME = "zn";
SFS2X.Requests.System.LoginRequest.KEY_USER_NAME = "un";
SFS2X.Requests.System.LoginRequest.KEY_PASSWORD = "pw";
SFS2X.Requests.System.LoginRequest.KEY_PARAMS = "p";
SFS2X.Requests.System.LoginRequest.KEY_PRIVILEGE_ID = "pi";
SFS2X.Requests.System.LoginRequest.KEY_ID = "id";
SFS2X.Requests.System.LoginRequest.KEY_ROOMLIST = "rl";
SFS2X.Requests.System.LoginRequest.KEY_RECONNECTION_SECONDS = "rs";
SFS2X.Requests.System.LogoutRequest = SFS2X.Requests._BaseRequest.extend({init: function () {
    this._super(SFS2X.Requests.Logout)
}, validate: function (a) {
    if (null == a.mySelf)throw new SFS2X.Exceptions.SFSValidationError("LogoutRequest error", ["You are not logged in"]);
}, execute: function () {
}});
SFS2X.Requests.System.LogoutRequest.KEY_ZONE_NAME = "zn";
SFS2X.Requests.System.JoinRoomRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c, d) {
    this._super(SFS2X.Requests.JoinRoom);
    "string" == typeof a ? this._rName = a : "number" == typeof a ? this._rId = a : a instanceof SFS2X.Entities.SFSRoom && (this._rId = a.id, this._rName = a.name);
    this._password = b;
    this._roomIdToLeave = c;
    this._asSpectator = "boolean" == typeof d ? d : !1
}, validate: function () {
    if (null == this._rId && null == this._rName)throw new SFS2X.Exceptions.SFSValidationError("JoinRoomRequest Error", ["Missing Room id or name, please provide one of the two or an existing Room object"]);
}, execute: function (a) {
    a._isJoining = !0;
    0 <= this._rId ? this._reqObj[this.constructor.KEY_ROOM_ID] = this._rId : null != this._rName && (this._reqObj[this.constructor.KEY_ROOM_NAME] = this._rName);
    null != this._password && (this._reqObj[this.constructor.KEY_PASS] = this._password);
    null != this._roomIdToLeave && (this._reqObj[this.constructor.KEY_ROOM_TO_LEAVE] = this._roomIdToLeave);
    this._asSpectator && (this._reqObj[this.constructor.KEY_AS_SPECTATOR] = this._asSpectator)
}});
SFS2X.Requests.System.JoinRoomRequest.KEY_ROOM = "r";
SFS2X.Requests.System.JoinRoomRequest.KEY_USER_LIST = "ul";
SFS2X.Requests.System.JoinRoomRequest.KEY_ROOM_NAME = "n";
SFS2X.Requests.System.JoinRoomRequest.KEY_ROOM_ID = "i";
SFS2X.Requests.System.JoinRoomRequest.KEY_PASS = "p";
SFS2X.Requests.System.JoinRoomRequest.KEY_ROOM_TO_LEAVE = "rl";
SFS2X.Requests.System.JoinRoomRequest.KEY_AS_SPECTATOR = "sp";
SFS2X.Requests.System.CreateRoomRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.CreateRoom);
    this._settings = a;
    this._autoJoin = "boolean" == typeof b ? b : !1;
    this._roomToLeave = c
}, validate: function () {
    var a = [];
    (null == this._settings.name || 0 == this._settings.name.length) && a.push("Missing Room name");
    0 >= this._settings.maxUsers && a.push("Max number of users must be > 0");
    null != this._settings.extension && ((null == this._settings.extension.className || 0 == this._settings.extension.className.length) &&
        a.push("Missing Extension class name"), (null == this._settings.extension.id || 0 == this._settings.extension.id.length) && a.push("Missing Extension id"));
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("CreateRoomRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_NAME] = this._settings.name;
    this._reqObj[this.constructor.KEY_GROUP_ID] = this._settings.groupId;
    this._reqObj[this.constructor.KEY_PASSWORD] = this._settings.password;
    this._reqObj[this.constructor.KEY_ISGAME] = this._settings.isGame;
    this._reqObj[this.constructor.KEY_MAXUSERS] = this._settings.maxUsers;
    this._reqObj[this.constructor.KEY_MAXSPECTATORS] = this._settings.maxSpectators;
    this._reqObj[this.constructor.KEY_MAXVARS] = this._settings.maxVariables;
    if (null != this._settings.variables && 0 < this._settings.variables.length) {
        var a = [], b;
        for (b in this._settings.variables) {
            var c = this._settings.variables[b];
            c instanceof SFS2X.Entities.Variables.SFSRoomVariable && a.push(c.toArray())
        }
        this._reqObj[this.constructor.KEY_ROOMVARS] = a
    }
    null != this._settings.permissions &&
    (a = [], a.push(this._settings.permissions.allowNameChange), a.push(this._settings.permissions.allowPasswordStateChange), a.push(this._settings.permissions.allowPublicMessages), a.push(this._settings.permissions.allowResizing), this._reqObj[this.constructor.KEY_PERMISSIONS] = a);
    null != this._settings.events && (a = [], a.push(this._settings.events.allowUserEnter), a.push(this._settings.events.allowUserExit), a.push(this._settings.events.allowUserCountChange), a.push(this._settings.events.allowUserVariablesUpdate),
        this._reqObj[this.constructor.KEY_EVENTS] = a);
    null != this._settings.extension && (this._reqObj[this.constructor.KEY_EXTID] = this._settings.extension.id, this._reqObj[this.constructor.KEY_EXTCLASS] = this._settings.extension.className, null != this._settings.extension.propertiesFile && 0 < this._settings.extension.propertiesFile.length && (this._reqObj[this.constructor.KEY_EXTPROP] = this._settings.extension.propertiesFile));
    this._reqObj[this.constructor.KEY_AUTOJOIN] = this._autoJoin;
    null != this._roomToLeave && (this._reqObj[this.constructor.KEY_ROOM_TO_LEAVE] =
        this._roomToLeave.id)
}});
SFS2X.Requests.System.CreateRoomRequest.KEY_ROOM = "r";
SFS2X.Requests.System.CreateRoomRequest.KEY_NAME = "n";
SFS2X.Requests.System.CreateRoomRequest.KEY_PASSWORD = "p";
SFS2X.Requests.System.CreateRoomRequest.KEY_GROUP_ID = "g";
SFS2X.Requests.System.CreateRoomRequest.KEY_ISGAME = "ig";
SFS2X.Requests.System.CreateRoomRequest.KEY_MAXUSERS = "mu";
SFS2X.Requests.System.CreateRoomRequest.KEY_MAXSPECTATORS = "ms";
SFS2X.Requests.System.CreateRoomRequest.KEY_MAXVARS = "mv";
SFS2X.Requests.System.CreateRoomRequest.KEY_ROOMVARS = "rv";
SFS2X.Requests.System.CreateRoomRequest.KEY_PERMISSIONS = "pm";
SFS2X.Requests.System.CreateRoomRequest.KEY_EVENTS = "ev";
SFS2X.Requests.System.CreateRoomRequest.KEY_EXTID = "xn";
SFS2X.Requests.System.CreateRoomRequest.KEY_EXTCLASS = "xc";
SFS2X.Requests.System.CreateRoomRequest.KEY_EXTPROP = "xp";
SFS2X.Requests.System.CreateRoomRequest.KEY_AUTOJOIN = "aj";
SFS2X.Requests.System.CreateRoomRequest.KEY_ROOM_TO_LEAVE = "rl";
SFS2X.Requests.System.GenericMessageRequest = SFS2X.Requests._BaseRequest.extend({init: function () {
    this._super(SFS2X.Requests.GenericMessage);
    this._type = -1;
    this._recipient = this._params = this._message = this._user = this._room = null;
    this._sendMode = -1
}, validate: function (a) {
    if (0 > this._type)throw new SFS2X.Exceptions.SFSValidationError("GenericMessageRequest Error", ["Unsupported message type: " + this._type]);
    var b = [];
    switch (this._type) {
        case SFS2X.Requests.GenericMessageType.PUBLIC_MSG:
            this._validatePublicMessage(a,
                b);
            break;
        case SFS2X.Requests.GenericMessageType.PRIVATE_MSG:
            this._validatePrivateMessage(a, b);
            break;
        case SFS2X.Requests.GenericMessageType.OBJECT_MSG:
            this._validateObjectMessage(a, b);
            break;
        case SFS2X.Requests.GenericMessageType.BUDDY_MSG:
            this._validateBuddyMessage(a, b);
            break;
        default:
            this._validateSuperUserMessage(a, b)
    }
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("GenericMessageRequest Error", b);
}, execute: function (a) {
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE_TYPE] =
        this._type;
    switch (this._type) {
        case SFS2X.Requests.GenericMessageType.PUBLIC_MSG:
            this._executePublicMessage(a);
            break;
        case SFS2X.Requests.GenericMessageType.PRIVATE_MSG:
            this._executePrivateMessage(a);
            break;
        case SFS2X.Requests.GenericMessageType.OBJECT_MSG:
            this._executeObjectMessage(a);
            break;
        case SFS2X.Requests.GenericMessageType.BUDDY_MSG:
            this._executeBuddyMessage(a);
            break;
        default:
            this._executeSuperUserMessage(a)
    }
}, _validatePublicMessage: function (a, b) {
    (null == this._message || 0 == this._message.length) &&
    b.push("Public message is empty");
    null != this._room && !a.mySelf.isJoinedInRoom(this._room) && b.push("You are not joined in the target Room: " + this._room)
}, _validatePrivateMessage: function (a, b) {
    (null == this._message || 0 == this._message.length) && b.push("Private message is empty");
    0 > this._recipient && b.push("Invalid recipient id: " + this._recipient)
}, _validateObjectMessage: function (a, b) {
    null == this._params && b.push("Object message is null")
}, _validateBuddyMessage: function (a, b) {
    a.buddyManager.isInited || b.push("Buddy List not yet initialized; please send an InitBuddyRequest first");
    !1 == a.buddyManager.myOnlineState && b.push("Can't send messages while you are offline in the Buddy List system");
    (null == this._message || 0 == this._message.length) && b.push("Buddy message is empty");
    0 > this._recipient && b.push("Recipient is offline or not in your Buddy List")
}, _validateSuperUserMessage: function (a, b) {
    (null == this._message || 0 == this._message.length) && b.push("Moderator message is empty");
    switch (this._sendMode) {
        case SFS2X.Requests.MessageRecipientMode.TO_USER:
            this._recipient instanceof SFS2X.Entities.SFSUser ||
            b.push("SFSUser object expected as recipient");
            break;
        case SFS2X.Requests.MessageRecipientMode.TO_ROOM:
            this._recipient instanceof SFS2X.Entities.SFSRoom || b.push("SFSRoom object expected as recipient");
            break;
        case SFS2X.Requests.MessageRecipientMode.TO_GROUP:
            "string" != typeof this._recipient && b.push("String object (the groupId) expected as recipient")
    }
}, _executePublicMessage: function (a) {
    null == this._room && (this._room = a.lastJoinedRoom);
    if (null == this._room)throw new SFS2X.Exceptions.SFSError("User should be joined in a Room in order to send a public message");
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_ROOM_ID] = this._room.id;
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_USER_ID] = a.mySelf.id;
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE] = this._message;
    null != this._params && (this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS] = this._params)
}, _executePrivateMessage: function () {
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT] = this._recipient;
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE] =
        this._message;
    null != this._params && (this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS] = this._params)
}, _executeBuddyMessage: function () {
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT] = this._recipient;
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE] = this._message;
    null != this._params && (this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS] = this._params)
}, _executeSuperUserMessage: function () {
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE] =
        this._message;
    null != this._params && (this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS] = this._params);
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT_MODE] = this._sendMode;
    switch (this._sendMode) {
        case SFS2X.Requests.MessageRecipientMode.TO_USER:
            this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT] = this._recipient.id;
            break;
        case SFS2X.Requests.MessageRecipientMode.TO_ROOM:
            this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT] =
                this._recipient.id;
            break;
        case SFS2X.Requests.MessageRecipientMode.TO_GROUP:
            this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT] = this._recipient
    }
}, _executeObjectMessage: function (a) {
    null == this._room && (this._room = a.lastJoinedRoom);
    if (null == this._room)throw new SFS2X.Exceptions.SFSError("User should be joined in a Room in order to send an object message");
    a = [];
    if (null != this._recipient && this._recipient instanceof Array) {
        var b = this._recipient;
        if (b.length > this._room.capacity)throw new SFS2X.Exceptions.SFSError("The number of recipients is bigger than the target Room capacity: " +
            b.length);
        for (var c in b) {
            var d = b[c];
            d instanceof SFS2X.Entities.SFSUser ? a.push(d.id) : this._log.warn("Bad recipient in ObjectMessage recipient list: " + typeof d + "; expected type: SFSUser")
        }
    }
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_ROOM_ID] = this._room.id;
    this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS] = this._params;
    0 < a.length && (this._reqObj[SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT] = a)
}});
SFS2X.Requests.System.GenericMessageRequest.KEY_ROOM_ID = "r";
SFS2X.Requests.System.GenericMessageRequest.KEY_USER_ID = "u";
SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE = "m";
SFS2X.Requests.System.GenericMessageRequest.KEY_MESSAGE_TYPE = "t";
SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT = "rc";
SFS2X.Requests.System.GenericMessageRequest.KEY_RECIPIENT_MODE = "rm";
SFS2X.Requests.System.GenericMessageRequest.KEY_XTRA_PARAMS = "p";
SFS2X.Requests.System.GenericMessageRequest.KEY_SENDER_DATA = "sd";
SFS2X.Requests.System.ChangeRoomNameRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b) {
    this._super(SFS2X.Requests.ChangeRoomName);
    this._room = a;
    this._newName = b
}, validate: function () {
    var a = [];
    null == this._room && a.push("Provided Room is null");
    (null == this._newName || 0 == this._newName.length) && a.push("Invalid new room name: it must be a non-null and non-empty string");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("ChangeRoomNameRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_ROOM] =
        this._room.id;
    this._reqObj[this.constructor.KEY_NAME] = this._newName
}});
SFS2X.Requests.System.ChangeRoomNameRequest.KEY_ROOM = "r";
SFS2X.Requests.System.ChangeRoomNameRequest.KEY_NAME = "n";
SFS2X.Requests.System.ChangeRoomPasswordStateRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b) {
    this._super(SFS2X.Requests.ChangeRoomPassword);
    this._room = a;
    this._newPass = b
}, validate: function () {
    var a = [];
    null == this._room && a.push("Provided Room is null");
    null == this._newPass && a.push("Invalid new room name: it must be a non-null string");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("ChangeRoomPasswordStateRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_ROOM] =
        this._room.id;
    this._reqObj[this.constructor.KEY_PASS] = this._newPass
}});
SFS2X.Requests.System.ChangeRoomPasswordStateRequest.KEY_ROOM = "r";
SFS2X.Requests.System.ChangeRoomPasswordStateRequest.KEY_PASS = "p";
SFS2X.Requests.System.ObjectMessageRequest = SFS2X.Requests.System.GenericMessageRequest.extend({init: function (a, b, c) {
    this._super();
    this._type = SFS2X.Requests.GenericMessageType.OBJECT_MSG;
    this._params = a;
    this._room = b;
    this._recipient = c
}});
SFS2X.Requests.System.SetRoomVariablesRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b) {
    this._super(SFS2X.Requests.SetRoomVariables);
    this._roomVariables = a;
    this._room = b
}, validate: function (a) {
    var b = [];
    null != this._room ? this._room.containsUser(a.mySelf) || b.push("You are not joined in the target Room") : null == a.lastJoinedRoom && b.push("You are not joined in any Room");
    (null == this._roomVariables || 0 == this._roomVariables.length) && b.push("No variables were specified");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("SetRoomVariablesRequest Error",
        b);
}, execute: function (a) {
    var b = [], c;
    for (c in this._roomVariables)b.push(this._roomVariables[c].toArray());
    null == this._room && (this._room = a.lastJoinedRoom);
    this._reqObj[this.constructor.KEY_VAR_LIST] = b;
    this._reqObj[this.constructor.KEY_VAR_ROOM] = this._room.id
}});
SFS2X.Requests.System.SetRoomVariablesRequest.KEY_VAR_ROOM = "r";
SFS2X.Requests.System.SetRoomVariablesRequest.KEY_VAR_LIST = "vl";
SFS2X.Requests.System.SetUserVariablesRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.SetUserVariables);
    this._userVariables = a
}, validate: function () {
    var a = [];
    (null == this._userVariables || 0 == this._userVariables.length) && a.push("No variables were specified");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("SetUserVariablesRequest Error", a);
}, execute: function () {
    var a = [], b;
    for (b in this._userVariables)a.push(this._userVariables[b].toArray());
    this._reqObj[this.constructor.KEY_VAR_LIST] =
        a
}});
SFS2X.Requests.System.SetUserVariablesRequest.KEY_USER = "u";
SFS2X.Requests.System.SetUserVariablesRequest.KEY_VAR_LIST = "vl";
SFS2X.Requests.System.ExtensionRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.CallExtension);
    this._targetController = 1;
    this._extCmd = a;
    this._params = b;
    this._room = c;
    null == this._params && (this._params = {})
}, validate: function () {
    var a = [];
    (null == this._extCmd || 0 == this._extCmd.length) && a.push("Missing extension command");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("ExtensionRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_CMD] =
        this._extCmd;
    this._reqObj[this.constructor.KEY_ROOM] = null == this._room ? -1 : this._room.id;
    this._reqObj[this.constructor.KEY_PARAMS] = this._params
}});
SFS2X.Requests.System.ExtensionRequest.KEY_CMD = "c";
SFS2X.Requests.System.ExtensionRequest.KEY_PARAMS = "p";
SFS2X.Requests.System.ExtensionRequest.KEY_ROOM = "r";
SFS2X.Requests.System.LeaveRoomRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.LeaveRoom);
    this._room = a
}, validate: function (a) {
    if (1 > a.getJoinedRooms().length)throw new SFS2X.Exceptions.SFSValidationError("LeaveRoomRequest Error", ["You are not joined in any room"]);
}, execute: function () {
    null != this._room && (this._reqObj[this.constructor.KEY_ROOM_ID] = this._room.id)
}});
SFS2X.Requests.System.LeaveRoomRequest.KEY_ROOM_ID = "r";
SFS2X.Requests.System.SubscribeRoomGroupRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.SubscribeRoomGroup);
    this._groupId = a
}, validate: function () {
    var a = [];
    (null == this._groupId || 0 == this._groupId.length) && a.push("Invalid group id passed; must be a string with at least one character");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("SubscribeGroupRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_GROUP_ID] = this._groupId
}});
SFS2X.Requests.System.SubscribeRoomGroupRequest.KEY_GROUP_ID = "g";
SFS2X.Requests.System.SubscribeRoomGroupRequest.KEY_ROOM_LIST = "rl";
SFS2X.Requests.System.UnsubscribeRoomGroupRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.UnsubscribeRoomGroup);
    this._groupId = a
}, validate: function () {
    var a = [];
    (null == this._groupId || 0 == this._groupId.length) && a.push("Invalid group id passed; must be a string with at least one character");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("UnsubscribeGroupRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_GROUP_ID] = this._groupId
}});
SFS2X.Requests.System.UnsubscribeRoomGroupRequest.KEY_GROUP_ID = "g";
SFS2X.Requests.System.SpectatorToPlayerRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.SpectatorToPlayer);
    this._room = a
}, validate: function (a) {
    if (1 > a.getJoinedRooms().length)throw new SFS2X.Exceptions.SFSValidationError("SpectatorToPlayerRequest Error", ["You are not joined in any room"]);
}, execute: function (a) {
    null == this._room && (this._room = a.lastJoinedRoom);
    this._reqObj[this.constructor.KEY_ROOM_ID] = this._room.id
}});
SFS2X.Requests.System.SpectatorToPlayerRequest.KEY_ROOM_ID = "r";
SFS2X.Requests.System.SpectatorToPlayerRequest.KEY_USER_ID = "u";
SFS2X.Requests.System.SpectatorToPlayerRequest.KEY_PLAYER_ID = "p";
SFS2X.Requests.System.PlayerToSpectatorRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.PlayerToSpectator);
    this._room = a
}, validate: function (a) {
    if (1 > a.getJoinedRooms().length)throw new SFS2X.Exceptions.SFSValidationError("PlayerToSpectatorRequest Error", ["You are not joined in any room"]);
}, execute: function (a) {
    null == this._room && (this._room = a.lastJoinedRoom);
    this._reqObj[this.constructor.KEY_ROOM_ID] = this._room.id
}});
SFS2X.Requests.System.PlayerToSpectatorRequest.KEY_ROOM_ID = "r";
SFS2X.Requests.System.PlayerToSpectatorRequest.KEY_USER_ID = "u";
SFS2X.Requests.System.ChangeRoomCapacityRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.ChangeRoomCapacity);
    this._room = a;
    this._newMaxUsers = b;
    this._newMaxSpect = c
}, validate: function () {
    var a = [];
    null == this._room && a.push("Provided Room is null");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("ChangeRoomCapacityRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_ROOM] = this._room.id;
    this._reqObj[this.constructor.KEY_USER_SIZE] =
        this._newMaxUsers;
    this._reqObj[this.constructor.KEY_SPEC_SIZE] = this._newMaxSpect
}});
SFS2X.Requests.System.ChangeRoomCapacityRequest.KEY_ROOM = "r";
SFS2X.Requests.System.ChangeRoomCapacityRequest.KEY_USER_SIZE = "u";
SFS2X.Requests.System.ChangeRoomCapacityRequest.KEY_SPEC_SIZE = "s";
SFS2X.Requests.System.PublicMessageRequest = SFS2X.Requests.System.GenericMessageRequest.extend({init: function (a, b, c) {
    this._super();
    this._type = SFS2X.Requests.GenericMessageType.PUBLIC_MSG;
    this._message = a;
    this._room = c;
    this._params = b
}});
SFS2X.Requests.System.PrivateMessageRequest = SFS2X.Requests.System.GenericMessageRequest.extend({init: function (a, b, c) {
    this._super();
    this._type = SFS2X.Requests.GenericMessageType.PRIVATE_MSG;
    this._message = a;
    this._recipient = b;
    this._params = c
}});
SFS2X.Requests.System.ModeratorMessageRequest = SFS2X.Requests.System.GenericMessageRequest.extend({init: function (a, b, c) {
    this._super();
    if (null == b)throw new SFS2X.Exceptions.SFSError("Recipient mode cannot be null");
    this._type = SFS2X.Requests.GenericMessageType.MODERATOR_MSG;
    this._message = a;
    this._params = c;
    this._recipient = b.target;
    this._sendMode = b.mode
}});
SFS2X.Requests.System.AdminMessageRequest = SFS2X.Requests.System.GenericMessageRequest.extend({init: function (a, b, c) {
    this._super();
    if (null == b)throw new SFS2X.Exceptions.SFSError("Recipient mode cannot be null");
    this._type = SFS2X.Requests.GenericMessageType.ADMING_MSG;
    this._message = a;
    this._params = c;
    this._recipient = b.target;
    this._sendMode = b.mode
}});
SFS2X.Requests.System.KickUserRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.KickUser);
    null == c && (c = 5);
    0 > c && (c = 0);
    this._userId = a;
    this._message = b;
    this._delay = c
}, validate: function (a) {
    var b = [];
    !a.mySelf.isModerator() && !a.mySelf.isAdmin() && b.push("You don't have enough permissions to execute this request");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("KickUserRequest Error", b);
}, execute: function () {
    this._reqObj[this.constructor.KEY_USER_ID] = this._userId;
    this._reqObj[this.constructor.KEY_DELAY] = this._delay;
    null != this._message && 0 < this._message.length && (this._reqObj[this.constructor.KEY_MESSAGE] = this._message)
}});
SFS2X.Requests.System.KickUserRequest.KEY_USER_ID = "u";
SFS2X.Requests.System.KickUserRequest.KEY_MESSAGE = "m";
SFS2X.Requests.System.KickUserRequest.KEY_DELAY = "d";
SFS2X.Requests.System.BanUserRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c, d, e) {
    this._super(SFS2X.Requests.BanUser);
    null == c && (c = 1);
    null == d && (d = 5);
    null == e && (e = 24);
    this._userId = a;
    this._message = b;
    this._banMode = c;
    this._delay = d;
    this._durationHours = e
}, validate: function (a) {
    var b = [];
    !a.mySelf.isModerator() && !a.mySelf.isAdmin() && b.push("You don't have enough permissions to execute this request");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("BanUserRequest Error", b);
}, execute: function () {
    this._reqObj[this.constructor.KEY_USER_ID] =
        this._userId;
    this._reqObj[this.constructor.KEY_DELAY] = this._delay;
    this._reqObj[this.constructor.KEY_BAN_MODE] = this._banMode;
    this._reqObj[this.constructor.KEY_BAN_DURATION_HOURS] = this._durationHours;
    null != this._message && 0 < this._message.length && (this._reqObj[this.constructor.KEY_MESSAGE] = this._message)
}});
SFS2X.Requests.System.BanUserRequest.KEY_USER_ID = "u";
SFS2X.Requests.System.BanUserRequest.KEY_MESSAGE = "m";
SFS2X.Requests.System.BanUserRequest.KEY_DELAY = "d";
SFS2X.Requests.System.BanUserRequest.KEY_BAN_MODE = "b";
SFS2X.Requests.System.BanUserRequest.KEY_BAN_DURATION_HOURS = "dh";
SFS2X.Requests.System.ManualDisconnectionRequest = SFS2X.Requests._BaseRequest.extend({init: function () {
    this._super(SFS2X.Requests.ManualDisconnection)
}, validate: function () {
}, execute: function () {
}});
SFS2X.Requests.System.FindRoomsRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.FindRooms);
    null == c && (c = 0);
    this._matchExpr = a;
    this._groupId = b;
    this._limit = c
}, validate: function () {
    var a = [];
    null == this._matchExpr && a.push("Missing match expression");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("FindRoomsRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_EXPRESSION] = this._matchExpr._toArray();
    null != this._groupId && (this._reqObj[this.constructor.KEY_GROUP] =
        this._groupId);
    0 < this._limit && (this._reqObj[this.constructor.KEY_LIMIT] = this._limit)
}});
SFS2X.Requests.System.FindRoomsRequest.KEY_EXPRESSION = "e";
SFS2X.Requests.System.FindRoomsRequest.KEY_GROUP = "g";
SFS2X.Requests.System.FindRoomsRequest.KEY_LIMIT = "l";
SFS2X.Requests.System.FindRoomsRequest.KEY_FILTERED_ROOMS = "fr";
SFS2X.Requests.System.FindUsersRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.FindUsers);
    null == c && (c = 0);
    this._matchExpr = a;
    this._target = b;
    this._limit = c
}, validate: function () {
    var a = [];
    null == this._matchExpr && a.push("Missing match expression");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("FindUsersRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_EXPRESSION] = this._matchExpr._toArray();
    null != this._target && (this._target instanceof
        SFS2X.Entities.SFSRoom ? this._reqObj[this.constructor.KEY_ROOM] = this._target.id : "string" == typeof this._target ? this._reqObj[this.constructor.KEY_GROUP] = this._target : this._log.warn("Unsupport target type for FindUsersRequest: " + this._target));
    0 < this._limit && (this._reqObj[this.constructor.KEY_LIMIT] = this._limit)
}});
SFS2X.Requests.System.FindUsersRequest.KEY_EXPRESSION = "e";
SFS2X.Requests.System.FindUsersRequest.KEY_GROUP = "g";
SFS2X.Requests.System.FindUsersRequest.KEY_ROOM = "r";
SFS2X.Requests.System.FindUsersRequest.KEY_LIMIT = "l";
SFS2X.Requests.System.FindUsersRequest.KEY_FILTERED_USERS = "fu";
SFS2X.Requests.System.PingPongRequest = SFS2X.Requests._BaseRequest.extend({init: function () {
    this._super(SFS2X.Requests.PingPong)
}, validate: function () {
}, execute: function () {
}});
SFS2X.Requests.BuddyList.InitBuddyListRequest = SFS2X.Requests._BaseRequest.extend({init: function () {
    this._super(SFS2X.Requests.InitBuddyList)
}, validate: function (a) {
    var b = [];
    a.buddyManager.isInited() && b.push("Buddy List is already initialized");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("InitBuddyListRequest Error", b);
}, execute: function () {
}});
SFS2X.Requests.BuddyList.InitBuddyListRequest.KEY_BLIST = "bl";
SFS2X.Requests.BuddyList.InitBuddyListRequest.KEY_BUDDY_STATES = "bs";
SFS2X.Requests.BuddyList.InitBuddyListRequest.KEY_MY_VARS = "mv";
SFS2X.Requests.BuddyList.AddBuddyRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.AddBuddy);
    this._name = a
}, validate: function (a) {
    var b = [];
    a.buddyManager.isInited() || b.push("Buddy List not yet initialized; please send an InitBuddyRequest first");
    (null == this._name || 1 > this._name.length) && b.push("Invalid buddy name (null or empty string)");
    !1 == a.buddyManager.getMyOnlineState() && b.push("Can't add a buddy while you are offline in the Buddy List system");
    a = a.buddyManager.getBuddyByName(this._name);
    null != a && !a.isTemp() && b.push("Can't add buddy '" + this._name + "' because it is already in your list");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("AddBuddyRequest Error", b);
}, execute: function () {
    this._reqObj[this.constructor.KEY_BUDDY_NAME] = this._name
}});
SFS2X.Requests.BuddyList.AddBuddyRequest.KEY_BUDDY_NAME = "bn";
SFS2X.Requests.BuddyList.BlockBuddyRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b) {
    this._super(SFS2X.Requests.BlockBuddy);
    this._name = a;
    this._blocked = b
}, validate: function (a) {
    var b = [];
    a.buddyManager.isInited() || b.push("Buddy List not yet initialized; please send an InitBuddyRequest first");
    (null == this._name || 1 > this._name.length) && b.push("Invalid buddy name (null or empty string)");
    !1 == a.buddyManager.getMyOnlineState() && b.push("Can't block a buddy while you are offline in the Buddy List system");
    a = a.buddyManager.getBuddyByName(this._name);
    null == a ? b.push("Can't block buddy '" + this._name + "' because it isn't in your list") : a.isBlocked() == this._blocked && b.push("Block flag is already in the requested '" + this._blocked + "' state for buddy " + this._name);
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("BlockBuddyRequest Error", b);
}, execute: function () {
    this._reqObj[this.constructor.KEY_BUDDY_NAME] = this._name;
    this._reqObj[this.constructor.KEY_BUDDY_BLOCK_STATE] = this._blocked
}});
SFS2X.Requests.BuddyList.BlockBuddyRequest.KEY_BUDDY_NAME = "bn";
SFS2X.Requests.BuddyList.BlockBuddyRequest.KEY_BUDDY_BLOCK_STATE = "bs";
SFS2X.Requests.BuddyList.RemoveBuddyRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.RemoveBuddy);
    this._name = a
}, validate: function (a) {
    var b = [];
    a.buddyManager.isInited() || b.push("Buddy List not yet initialized; please send an InitBuddyRequest first");
    !1 == a.buddyManager.getMyOnlineState() && b.push("Can't remove a buddy while you are offline in the Buddy List system");
    a.buddyManager.containsBuddy(this._name) || b.push("Can't remove buddy '" + this._name + "' because it isn't in your list");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("RemoveBuddyRequest Error", b);
}, execute: function () {
    this._reqObj[this.constructor.KEY_BUDDY_NAME] = this._name
}});
SFS2X.Requests.BuddyList.RemoveBuddyRequest.KEY_BUDDY_NAME = "bn";
SFS2X.Requests.BuddyList.SetBuddyVariablesRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.SetBuddyVariables);
    this._buddyVariables = a
}, validate: function (a) {
    var b = [];
    a.buddyManager.isInited() || b.push("Buddy List not yet initialized; please send an InitBuddyRequest first");
    !1 == a.buddyManager.getMyOnlineState() && b.push("Can't set Buddy Variables while you are offline in the Buddy List system");
    (null == this._buddyVariables || 0 == this._buddyVariables.length) && b.push("No Buddy Variables to set have been specified");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("SetBuddyVariablesRequest Error", b);
}, execute: function () {
    var a = [], b;
    for (b in this._buddyVariables) {
        var c = this._buddyVariables[b];
        c instanceof SFS2X.Entities.Variables.SFSBuddyVariable && a.push(c.toArray())
    }
    this._reqObj[this.constructor.KEY_BUDDY_VARS] = a
}});
SFS2X.Requests.BuddyList.SetBuddyVariablesRequest.KEY_BUDDY_NAME = "bn";
SFS2X.Requests.BuddyList.SetBuddyVariablesRequest.KEY_BUDDY_VARS = "bv";
SFS2X.Requests.BuddyList.GoOnlineRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.GoOnline);
    this._online = a
}, validate: function (a) {
    var b = [];
    a.buddyManager.isInited() || b.push("Buddy List not yet initialized; please send an InitBuddyRequest first");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("GoOnlineRequest Error", b);
}, execute: function (a) {
    a.buddyManager._setMyOnlineState(this._online);
    this._reqObj[this.constructor.KEY_ONLINE] = this._online
}});
SFS2X.Requests.BuddyList.GoOnlineRequest.KEY_ONLINE = "o";
SFS2X.Requests.BuddyList.GoOnlineRequest.KEY_BUDDY_NAME = "bn";
SFS2X.Requests.BuddyList.GoOnlineRequest.KEY_BUDDY_ID = "bi";
SFS2X.Requests.BuddyList.BuddyMessageRequest = SFS2X.Requests.System.GenericMessageRequest.extend({init: function (a, b, c) {
    this._super();
    this._type = SFS2X.Requests.GenericMessageType.BUDDY_MSG;
    this._message = a;
    this._recipient = null != b ? b.id : -1;
    this._params = c
}});
SFS2X.Requests.Game.InviteUsersRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.InviteUsers);
    this._invitedUsers = a;
    this._secondsForAnswer = b;
    this._params = c
}, validate: function () {
    var a = [];
    (null == this._invitedUsers || 1 > this._invitedUsers.length) && a.push("No invitation(s) to send");
    this._invitedUsers.length > this.constructor.MAX_INVITATIONS_FROM_CLIENT_SIDE && a.push("Too many invitations; " + this.constructor.MAX_INVITATIONS_FROM_CLIENT_SIDE + " max are allowed from client side");
    (this._secondsForAnswer < this.constructor.MIN_EXPIRY_TIME || this._secondsForAnswer > this.constructor.MAX_EXPIRY_TIME) && a.push("secondsForAnswer value is out of range (min: " + this.constructor.MIN_EXPIRY_TIME + "; max: " + this.constructor.MAX_EXPIRY_TIME + ")");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("InviteUsersRequest Error", a);
}, execute: function (a) {
    var b = [], c;
    for (c in this._invitedUsers) {
        var d = this._invitedUsers[c];
        (d instanceof SFS2X.Entities.SFSUser || d instanceof SFS2X.Entities.SFSBuddy) &&
            d != a.mySelf && b.push(d.id)
    }
    this._reqObj[this.constructor.KEY_INVITED_USERS] = b;
    this._reqObj[this.constructor.KEY_TIME] = this._secondsForAnswer;
    null != this._params && (this._reqObj[this.constructor.KEY_PARAMS] = this._params)
}});
SFS2X.Requests.Game.InviteUsersRequest.KEY_USER = "u";
SFS2X.Requests.Game.InviteUsersRequest.KEY_USER_ID = "ui";
SFS2X.Requests.Game.InviteUsersRequest.KEY_INVITATION_ID = "ii";
SFS2X.Requests.Game.InviteUsersRequest.KEY_TIME = "t";
SFS2X.Requests.Game.InviteUsersRequest.KEY_PARAMS = "p";
SFS2X.Requests.Game.InviteUsersRequest.KEY_INVITEE_ID = "ee";
SFS2X.Requests.Game.InviteUsersRequest.KEY_INVITED_USERS = "iu";
SFS2X.Requests.Game.InviteUsersRequest.KEY_REPLY_ID = "ri";
SFS2X.Requests.Game.InviteUsersRequest.MAX_INVITATIONS_FROM_CLIENT_SIDE = 8;
SFS2X.Requests.Game.InviteUsersRequest.MIN_EXPIRY_TIME = 5;
SFS2X.Requests.Game.InviteUsersRequest.MAX_EXPIRY_TIME = 300;
SFS2X.Requests.Game.InvitationReplyRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.InvitationReply);
    this._invitation = a;
    this._reply = b;
    this._params = c
}, validate: function () {
    var a = [];
    null == this._invitation && a.push("Missing invitation object");
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("InvitationReplyRequest Error", a);
}, execute: function () {
    this._reqObj[this.constructor.KEY_INVITATION_ID] = this._invitation.id;
    this._reqObj[this.constructor.KEY_INVITATION_REPLY] =
        this._reply;
    null != this._params && (this._reqObj[this.constructor.KEY_INVITATION_PARAMS] = this._params)
}});
SFS2X.Requests.Game.InvitationReplyRequest.KEY_INVITATION_ID = "i";
SFS2X.Requests.Game.InvitationReplyRequest.KEY_INVITATION_REPLY = "r";
SFS2X.Requests.Game.InvitationReplyRequest.KEY_INVITATION_PARAMS = "p";
SFS2X.Requests.Game.CreateSFSGameRequest = SFS2X.Requests._BaseRequest.extend({init: function (a) {
    this._super(SFS2X.Requests.CreateSFSGame);
    this._settings = a;
    this._createRoomRequest = new SFS2X.Requests.System.CreateRoomRequest(a, !1, null)
}, validate: function (a) {
    var b = [];
    try {
        this._createRoomRequest.validate(a)
    } catch (c) {
        b = c.getErrors()
    }
    this._settings.minPlayersToStartGame > this._settings.maxUsers && b.push("Minimum number of players to start the game can't be greater than the Room's maximum number of users");
    (this._settings.invitationExpiryTime < SFS2X.Requests.Game.InviteUsersRequest.MIN_EXPIRY_TIME || this._settings.invitationExpiryTime > SFS2X.Requests.Game.InviteUsersRequest.MAX_EXPIRY_TIME) && b.push("Invitation expiration time value is out of range (min: " + SFS2X.Requests.Game.InviteUsersRequest.MIN_EXPIRY_TIME + "; max: " + SFS2X.Requests.Game.InviteUsersRequest.MAX_EXPIRY_TIME + ")");
    null != this._settings.invitedPlayers && this._settings.invitedPlayers.length > SFS2X.Requests.Game.InviteUsersRequest.MAX_INVITATIONS_FROM_CLIENT_SIDE &&
    b.push("Can't invite more than " + SFS2X.Requests.Game.InviteUsersRequest.MAX_INVITATIONS_FROM_CLIENT_SIDE + " players from client side");
    if (0 < b.length)throw new SFS2X.Exceptions.SFSValidationError("CreateSFSGameRequest Error", b);
}, execute: function (a) {
    this._createRoomRequest.execute(a);
    this._reqObj = this._createRoomRequest._reqObj;
    this._reqObj[this.constructor.KEY_IS_PUBLIC] = this._settings.isPublic;
    this._reqObj[this.constructor.KEY_MIN_PLAYERS] = this._settings.minPlayersToStartGame;
    this._reqObj[this.constructor.KEY_INVITATION_EXPIRY] =
        this._settings.invitationExpiryTime;
    this._reqObj[this.constructor.KEY_LEAVE_ROOM] = this._settings.leaveLastJoinedRoom;
    this._reqObj[this.constructor.KEY_NOTIFY_GAME_STARTED] = this._settings.notifyGameStarted;
    null != this._settings.playerMatchExpression && (this._reqObj[this.constructor.KEY_PLAYER_MATCH_EXP] = this._settings.playerMatchExpression._toArray());
    null != this._settings.spectatorMatchExpression && (this._reqObj[this.constructor.KEY_SPECTATOR_MATCH_EXP] = this._settings.spectatorMatchExpression._toArray());
    if (null != this._settings.invitedPlayers) {
        var a = [], b;
        for (b in this._settings.invitedPlayers) {
            var c = this._settings.invitedPlayers[b];
            (c instanceof SFS2X.Entities.SFSUser || c instanceof SFS2X.Entities.SFSBuddy) && a.push(c.id)
        }
        this._reqObj[this.constructor.KEY_INVITED_PLAYERS] = a
    }
    null != this._settings.searchableRooms && (this._reqObj[this.constructor.KEY_SEARCHABLE_ROOMS] = this._settings.searchableRooms);
    null != this._settings.invitationParams && (this._reqObj[this.constructor.KEY_INVITATION_PARAMS] = this._settings.invitationParams)
}});
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_IS_PUBLIC = "gip";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_MIN_PLAYERS = "gmp";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_INVITED_PLAYERS = "ginp";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_SEARCHABLE_ROOMS = "gsr";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_PLAYER_MATCH_EXP = "gpme";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_SPECTATOR_MATCH_EXP = "gsme";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_INVITATION_EXPIRY = "gie";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_LEAVE_ROOM = "glr";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_NOTIFY_GAME_STARTED = "gns";
SFS2X.Requests.Game.CreateSFSGameRequest.KEY_INVITATION_PARAMS = "ip";
SFS2X.Requests.Game.QuickJoinGameRequest = SFS2X.Requests._BaseRequest.extend({init: function (a, b, c) {
    this._super(SFS2X.Requests.QuickJoinGame);
    this._matchExpression = a;
    this._whereToSearch = b;
    this._roomToLeave = c
}, validate: function () {
    var a = [];
    null == this._whereToSearch || 1 > this._whereToSearch.length ? a.push("Missing lis of Rooms or Group name where to search the game to join") : this._whereToSearch.length > this.constructor.MAX_ROOMS && a.push("Too many Rooms specified in list where to search the game to join; client limit is: " +
        this.constructor.MAX_ROOMS);
    if (0 < a.length)throw new SFS2X.Exceptions.SFSValidationError("CreateSFSGameRequest Error", a);
}, execute: function () {
    if ("string" == typeof this._whereToSearch[0])this._reqObj[this.constructor.KEY_GROUP_LIST] = this._whereToSearch; else if (this._whereToSearch[0]instanceof SFS2X.Entities.SFSRoom) {
        for (var a = [], b = 0; b < this._whereToSearch.length; b++) {
            var c = this._whereToSearch[b];
            c instanceof SFS2X.Entities.SFSRoom && a.push(c.id)
        }
        this._reqObj[this.constructor.KEY_ROOM_LIST] = a
    } else throw new SFS2X.Exceptions.SFSError("Invalid type in whereToSearch parameter");
    null != this._roomToLeave && (this._reqObj[this.constructor.KEY_ROOM_TO_LEAVE] = this._roomToLeave.id);
    null != this._matchExpression && (this._reqObj[this.constructor.KEY_MATCH_EXPRESSION] = this._matchExpression._toArray())
}});
SFS2X.Requests.Game.QuickJoinGameRequest.KEY_ROOM_LIST = "rl";
SFS2X.Requests.Game.QuickJoinGameRequest.KEY_GROUP_LIST = "gl";
SFS2X.Requests.Game.QuickJoinGameRequest.KEY_ROOM_TO_LEAVE = "tl";
SFS2X.Requests.Game.QuickJoinGameRequest.KEY_MATCH_EXPRESSION = "me";
SFS2X.Requests.Game.QuickJoinGameRequest.MAX_ROOMS = 32;
SFS2X.Requests.Handshake = 0;
SFS2X.Requests.Login = 1;
SFS2X.Requests.Logout = 2;
SFS2X.Requests.JoinRoom = 4;
SFS2X.Requests.CreateRoom = 6;
SFS2X.Requests.GenericMessage = 7;
SFS2X.Requests.ChangeRoomName = 8;
SFS2X.Requests.ChangeRoomPassword = 9;
SFS2X.Requests.SetRoomVariables = 11;
SFS2X.Requests.SetUserVariables = 12;
SFS2X.Requests.CallExtension = 13;
SFS2X.Requests.LeaveRoom = 14;
SFS2X.Requests.SubscribeRoomGroup = 15;
SFS2X.Requests.UnsubscribeRoomGroup = 16;
SFS2X.Requests.SpectatorToPlayer = 17;
SFS2X.Requests.PlayerToSpectator = 18;
SFS2X.Requests.ChangeRoomCapacity = 19;
SFS2X.Requests.KickUser = 24;
SFS2X.Requests.BanUser = 25;
SFS2X.Requests.ManualDisconnection = 26;
SFS2X.Requests.FindRooms = 27;
SFS2X.Requests.FindUsers = 28;
SFS2X.Requests.PingPong = 29;
SFS2X.Requests.InitBuddyList = 200;
SFS2X.Requests.AddBuddy = 201;
SFS2X.Requests.BlockBuddy = 202;
SFS2X.Requests.RemoveBuddy = 203;
SFS2X.Requests.SetBuddyVariables = 204;
SFS2X.Requests.GoOnline = 205;
SFS2X.Requests.InviteUsers = 300;
SFS2X.Requests.InvitationReply = 301;
SFS2X.Requests.CreateSFSGame = 302;
SFS2X.Requests.QuickJoinGame = 303;
SFS2X.Requests.getRequestNameFromId = function (a) {
    for (var b in SFS2X.Requests)if (SFS2X.Requests[b] == a)return b;
    return null
};
SFS2X.Requests.RoomSettings = Class.extend({init: function (a) {
    this.name = a;
    this.password = "";
    this.groupId = "default";
    this.isGame = !1;
    this.maxUsers = 10;
    this.maxSpectators = 0;
    this.maxVariables = 5;
    this.variables = [];
    this.extension = this.events = this.permissions = null
}});
SFS2X.Requests.Game.SFSGameSettings = SFS2X.Requests.RoomSettings.extend({init: function (a) {
    this._super(a);
    this.isPublic = !0;
    this.minPlayersToStartGame = 2;
    this.searchableRooms = this.invitedPlayers = null;
    this.invitationExpiryTime = 15;
    this.leaveLastJoinedRoom = !0;
    this.notifyGameStarted = !1;
    this.invitationParams = this.spectatorMatchExpression = this.playerMatchExpression = null
}});
SFS2X.Requests.RoomPermissions = function () {
    this.allowPasswordStateChange = this.allowNameChange = !1;
    this.allowPublicMessages = !0;
    this.allowResizing = !1
};
SFS2X.Requests.RoomEvents = function () {
    this.allowUserVariablesUpdate = this.allowUserExit = this.allowUserEnter = this.allowUserCountChange = !1
};
SFS2X.Requests.RoomExtension = function (a, b) {
    this.id = a;
    this.className = b;
    this.propertiesFile = ""
};
SFS2X.Requests.GenericMessageType = {};
SFS2X.Requests.GenericMessageType.PUBLIC_MSG = 0;
SFS2X.Requests.GenericMessageType.PRIVATE_MSG = 1;
SFS2X.Requests.GenericMessageType.MODERATOR_MSG = 2;
SFS2X.Requests.GenericMessageType.ADMING_MSG = 3;
SFS2X.Requests.GenericMessageType.OBJECT_MSG = 4;
SFS2X.Requests.GenericMessageType.BUDDY_MSG = 5;
SFS2X.Requests.MessageRecipientMode = function (a, b) {
    if (a < this.TO_USER || a > this.TO_ZONE)throw new SFS2X.Exceptions.SFSError("Illegal recipient mode: " + a);
    this.mode = a;
    this.target = b
};
SFS2X.Requests.MessageRecipientMode.TO_USER = 0;
SFS2X.Requests.MessageRecipientMode.TO_ROOM = 1;
SFS2X.Requests.MessageRecipientMode.TO_GROUP = 2;
SFS2X.Requests.MessageRecipientMode.TO_ZONE = 3;
SFS2X.Requests.BanMode = {};
SFS2X.Requests.BanMode.BY_ADDRESS = 0;
SFS2X.Requests.BanMode.BY_NAME = 1;
SFS2X.SocketEngine = function (a) {
    this.isConnecting = this.isConnected = !1;
    this.reconnectionSeconds = 0;
    this._controllers = {};
    this._log = SFS2X.Logger;
    this._socket = null;
    this._maxMessageSize = 1E4;
    this._sfs = a;
    this._lastTcpPort = 0;
    this._reconnectionDelayMillis = 1E3;
    this._attemptingReconnection = this._isReconnecting = !1;
    this._eventDispatcher = new SFS2X.EventDispatcher;
    this._disconnectionReason = SFS2X.Utils.ClientDisconnectionReason.UNKNOWN
};
SFS2X.SocketEngine.prototype.connect = function (a, b) {
    this.isConnected ? this._log.error("Connection is already active") : this.isConnecting ? this._log.error("A connection attempt is already in progress") : (this.isConnecting = !0, this._socket = new WebSocket("ws://" + a + ":" + b + "/"), this._socket._scope = this, this._socket.onopen = this._onSocketConnect, this._socket.onclose = this._onSocketDisconnect, this._socket.onmessage = this._onSocketData, this._socket.onerror = this._onSocketError)
};
SFS2X.SocketEngine.prototype.disconnect = function (a) {
    this._disconnectionReason = a;
    this._socket.close()
};
SFS2X.SocketEngine.prototype.addEventListener = function (a, b, c) {
    this._eventDispatcher.addEventListener(a, b, c)
};
SFS2X.SocketEngine.prototype.removeEventListener = function (a, b) {
    this._eventDispatcher.removeEventListener(a, b)
};
SFS2X.SocketEngine.prototype.addController = function (a, b) {
    null == this._controllers[a] && (this._controllers[a] = b)
};
SFS2X.SocketEngine.prototype.removeController = function (a) {
    delete this._controllers[a]
};
SFS2X.SocketEngine.prototype.send = function (a) {
    a = this._encodeMessage(a);
    this._socket.send(a)
};
SFS2X.SocketEngine.prototype._decodeMessage = function (a) {
    return JSON.parse(a)
};
SFS2X.SocketEngine.prototype._encodeMessage = function (a) {
    return JSON.stringify(a)
};
SFS2X.SocketEngine.prototype._onSocketConnect = function () {
    this._scope.isConnected = !0;
    this._scope.isConnecting = !1;
    this._scope._log.debug("SOCKET CONNECTION OK");
    this._scope._eventDispatcher.dispatchEvent(SFS2X.SocketEvent.CONNECT, {success: !0, isReconnection: this._scope._attemptingReconnection})
};
SFS2X.SocketEngine.prototype._onSocketDisconnect = function () {
    this._scope.isConnected = !1;
    if (this._scope.isConnecting) {
        this._scope.isConnecting = !1;
        var a = {success: !1, isReconnection: this._scope._attemptingReconnection};
        this._scope._eventDispatcher.dispatchEvent(SFS2X.SocketEvent.CONNECT, a)
    } else a = {reason: this._scope._disconnectionReason}, this._scope._eventDispatcher.dispatchEvent(SFS2X.SocketEvent.DISCONNECT, a), this._scope._disconnectionReason = SFS2X.Utils.ClientDisconnectionReason.UNKNOWN
};
SFS2X.SocketEngine.prototype._onSocketData = function (a) {
    this._scope._eventDispatcher.dispatchEvent(SFS2X.SocketEvent.DATA, this._scope._decodeMessage(a.data))
};
SFS2X.SocketEngine.prototype._onSocketError = function (a) {
    this._scope._eventDispatcher.dispatchEvent(SFS2X.SocketEvent.IOERROR, a.data)
};
SFS2X.SocketEvent = {CONNECT: "socketConnect", DISCONNECT: "socketDisconnect", DATA: "data", IOERROR: "socketIOError"};
